A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: AS3 : Targeting another movie clip to animate

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    9

    AS3 : Targeting another movie clip to animate

    Hi All,

    I'm very new to flash.
    Can someone tell me how to target to the another movie clip to animate?

    I was using code as below but the output is not really correct.
    It seemed something is duplicating (I just suppected)

    PHP Code:
    import flash.display.MovieClip;

    var 
    mc_Ripple:MovieClip = new Ripple_Text() ;
    mc_Ripple.315;
    mc_Ripple.40;

    addChild(mc_Ripple);
    mc_Ripple.gotoAndPlay(2); 
    I'm attaching the swf because the fla is too big.
    CIA.zip


    Thanks

  2. #2
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    Assuming Ripple_Text is a class that extends MovieClip, nothing is wrong with the code you posted.

    What error message are you receiving?
    Search first, asked questions later.

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    9
    Thanks Ralgoth for your reply and help^^

    If you downloaded my swf and see you would see the text became weird after 1st jumping and the movie became more and more slow. What was caused this problem?
    Last edited by zhixuen; 12-16-2009 at 08:07 PM.

  4. #4
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    I can't download your swf from this location (company regulations). I can look at it if you publish it and give a url...

    but from your description it sounds like you have this in a loop, and are creating a new instance of the Ripple_Text class each pass.

    it looks like your code is in the timeline. If the timeline is playing, and looping, then that would be the cause. You'll need to make sure that the script is only run once. add a trace('new Ripple_Text()'); to the code above and see if it fires more than once.
    Search first, asked questions later.

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    9
    If you're in right way. How could I solve this problem?
    I was thinking same way as you but I couldn't find the solution to overcome it.
    My movie execute the animation in timeline. So It is repeating until I stop the movie.
    That's the reason the movie clip keep duplicating in a loop.

    Is any web host can publish flash file because I won't publish the flash to internet.
    The flash is using for our company carnival presentation.

    Thanks :-)

  6. #6
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    what you could do, is in the first frame of the timeline, place the code from above. then, instead of letting it loop, add gotoAndPlay(2); on the last frame. that way it won't run the script a 2nd time.
    Search first, asked questions later.

  7. #7
    Junior Member
    Join Date
    Jan 2009
    Posts
    9
    In fact the AS was placed at the last frame in a classic tween timeline.
    The last frame will redirect the animation to another movie clip and execute the animation on targeted movie clip.
    I wanted the action above to be repeated.
    In AS2 and below we could use TellTarget to achieve it.
    Howabout in AS3?

  8. #8
    Junior Member
    Join Date
    Jan 2009
    Posts
    9
    Thanks Ralgoth,

    I had found the solution by just added a checking for movieclip existance.
    That's worked for me.

    PHP Code:
    import flash.display.MovieClip;

    if (
    mc_Ripple == null )  {

    var 
    mc_Ripple:Ripple_Text = new Ripple_Text() ;
    mc_Ripple.315;
    mc_Ripple.40;

    addChild(mc_Ripple);
    }

    mc_Ripple.gotoAndPlay(2); 

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