PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
CS3 duplicateMovieClip and for loop problem
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: duplicateMovieClip and for loop problem

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    95

    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?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    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});
    	};
    }

  3. #3
    Member
    Join Date
    Aug 2007
    Posts
    95
    Thanks, now it's working

    Maybe would you like to explain why generated temp_mc isn't doing the job?

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center