|
-
duplicateMovieClip and for loop problem
Hi,
I'm creating a flash menu and I have this AS code on the first frame:
Actionscript Code:
import com.greensock.*; import com.greensock.easing.*; TweenPlugin.activate([BlurFilterPlugin, ColorMatrixFilterPlugin, EndArrayPlugin, AutoAlphaPlugin, FrameLabelPlugin, GlowFilterPlugin]);
mc_main.mc_title._alpha = 0; mc_main.mc_title._y = -20; TweenLite.to(mc_main.mc_title, 1.5, {_y:-5.5, delay:1, _alpha:100, ease:Back.easeOut});
for (i=0;i<6;i++){ var temp_mc = mc_main.duplicateMovieClip("mc_main"+i, i+10); TweenLite.to(temp_mc, 1.5, {_y:60+(temp_mc._height-20)*i, delay:i*0.5, _alpha:100, ease:Back.easeOut}); TweenMax.to(temp_mc.plane, 0, {colorMatrixFilter:{colorize:0x333333, amount:1, contrast:3, brightness:2}}); temp_mc.onRollOver = function(){ _root.temp_mc.gotoAndStop("s1"); TweenLite.to(temp_mc.mc_title, 1, {glowFilter:{color:0xffff00, alpha:1, blurX:15, blurY:15, quality:3}, ease:Sine.easeOut}); } temp_mc.onRollOut = function(){ _root.temp_mc.gotoAndStop("s2"); TweenLite.to(temp_mc.mc_title, 1, {glowFilter:{alpha:0}, ease:Sine.easeOut}); } }
My problem is, that when these MC's duplicates, there is only one (last) which is working.
You can see it in action here: http://mweb.lt/problem.html
Can someone help me to fix it?
-
Code:
for (i=0; i<6; i++) {
var temp_mc = mc_main.duplicateMovieClip("mc_main"+i, i+10);
TweenLite.to(temp_mc,1.5,{_y:60+(temp_mc._height-20)*i, delay:i*0.5, _alpha:100, ease:Back.easeOut});
TweenMax.to(temp_mc.plane,0,{colorMatrixFilter:{colorize:0x333333, amount:1, contrast:3, brightness:2}});
temp_mc.onRollOver = function() {
var mc = this;
mc.gotoAndStop("s1");
TweenLite.to(mc.mc_title,1,{glowFilter:{color:0xffff00, alpha:1, blurX:15, blurY:15, quality:3}, ease:Sine.easeOut});
};
temp_mc.onRollOut = function() {
var mc = this;
mc.gotoAndStop("s2");
TweenLite.to(mc.mc_title,1,{glowFilter:{alpha:0}, ease:Sine.easeOut});
};
}
-
Thanks, now it's working 
Maybe would you like to explain why generated temp_mc isn't doing the job?
-
The variable temp_mc is established in the for loop. At the completion of the for loop, temp_mc is equal to the last duplicated movie clip. So when any of the roll over functions were called, that was the value used - that of the last duplicated movie clip.
HTH
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|