Bonjour,
J'ai le problème suivant : j'ai défini une classe AS2 qui m'affiche correctement ce que je veux mais il y a un hic. La méthode TracerlePolygone ne s'exécute qu'au démarrage alors qu'elle devrait l'être à chaque fois qu'un élément de l'animation est "draggé". Qu'est-ce qui cloche ?

Merci d'avance.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
class Polygon extends MovieClip {
var nbr:Number= 10;
var cote:Number = 6;
var cx:Number= 150;
var cy:Number= 150;
var rayon:Number = 100;
var xmax:Number = 275;
var xmin:Number = 25;
var ymin:Number = 25;
var ymax:Number = 275;
 
	public function Polygon() {
 
var zone=this.createEmptyMovieClip("zone", 0);
zone.lineStyle(0, 0, 100);
zone.beginFill("0x999999", 15);
zone.moveTo(xmin, ymin);
zone.lineTo(xmax, ymin);
zone.lineTo(xmax, ymax);
zone.lineTo(xmin, ymax);
zone.lineTo(xmin, ymin);
zone.endFill();
 
 
 
for (var i = 0; i<nbr; i++) {
this.createEmptyMovieClip("sommet"+i, i+3);
var angle = i*2*Math.PI/nbr;
 
 
this["sommet"+i].beginFill(0, 100);
this["sommet"+i].moveTo(-0.5*cote, -0.5*cote);
this["sommet"+i].lineTo(-0.5*cote, 0.5*cote);
this["sommet"+i].lineTo(0.5*cote, 0.5*cote);
this["sommet"+i].lineTo(0.5*cote, -0.5*cote);
this["sommet"+i].lineTo(-0.5*cote, -0.5*cote);
this["sommet"+i].endFill();
this["sommet"+i]._x = cx+rayon*Math.cos(angle);
this["sommet"+i]._y = cy+rayon*Math.sin(angle);
 
 
this["sommet"+i].onPress = function() {
this.startDrag(false, xmin, ymin, xmax, ymax);
this._parent.onEnterFrame = tracerLePolygone();
};
 
this["sommet"+i].onRelease = this["sommet"+i].onReleaseOutside=function () {
 
	this.stopDrag();
delete this._parent.onEnterFrame;
this.tracerLePolygone();
trace(this["polygone"]);
};
}
this.tracerLePolygone();
	}
 
	private function tracerLePolygone () {
trace("Test");
var polygone=this.createEmptyMovieClip("polygone", 1);
 
polygone.clear();
 
polygone.lineStyle(0, "0x999999", 100);
polygone.moveTo(this["sommet"+0]._x, this["sommet"+0]._y);
 
for (var i = 1; i<nbr; i++) {
polygone.lineTo(this["sommet"+i]._x, this["sommet"+i]._y);
}
polygone.lineTo(this["sommet"+0]._x, this["sommet"+0]._y);
}
}