Bonjour,
je souhaite automatiser mes effets, à commencer par le fadeIn/Out directionnel sur les MovieClip.
Pour des raisons de compatibilité, il faut que cela soit en AS2 et Flash 7. Voici le code que j'ai pondu :
Et sur le clip en question j'ai :
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 function eAlpha(obj, duree, dist, dir, arrives) { distStep = (dist/duree); if (arrives) { alph = 0; alphTo = 100; } else { alph = 100; alphTo = 0; } alphStep = Math.round((alphTo-alph)/duree); if (arrives) { toX = obj._x; toY = obj._y; } else { fromX = obj._x; fromY = obj._y; } switch (dir) { case "H" : case "T" : if (arrives) { fromY = toY-dist; fromX = toX; toI = distStep; } else { toX = fromX; toY = fromY-dist; toI = -distStep; } break; case "D" : case "R" : if (arrives) { fromY = toY; fromX = toX+dist; toI = -distStep; } else { toX = fromX+dist; toY = fromY; toI = distStep; } break; case "B" : if (arrives) { fromY = toY+dist; fromX = toX; toI = -distStep; } else { toX = fromX; toY = fromY+dist; toI = distStep; } break; case "L" : case "G" : if (arrives) { fromY = toY; fromX = toX-dist; toI = distStep; break; } else { toX = fromX-dist; toY = fromY; toI = -distStep; } default : fromX = obj._x; fromY = obj._y; toX = obj._x; toY = obj._y; break; } obj._alpha = alph; obj._x = fromX; obj._y = fromY; frameLeft = duree; obj.onEnterFrame = function() { if (this._alpha+alphStep<>alphTo) { this._alpha = this._alpha+alphStep; } else { this._alpha = alphTo; } if (fromX<>toX && this._x<>toX) { this._x = this._x+toI; } if (fromY<>toY && this._y<>toY) { this._y = this._y+toI; } if (frameLeft--<=0) { delete this.onEnterFrame; } }; }
Ca fonctionne très bien tant que je n'utilise pas la fonction eAlpha simultanément sur plusieurs clips. Si je le fais, il y a partage de variables, or je ne comprends pas très bien pourquoi.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 onClipEvent(load) { _parent.eAlpha(this, 25, 30, "L", true); }
Par exemple, frameLeft est partagée, ce qui cause la fin de l'effet avant qu'il ne soit complété.
Merci de m'éclairer !
Partager