Skip to main content
TheOriginalGC
Community Expert
Community Expert
Mar 10, 2025 2:43 PM UTC
Question

Problem with nested movie clip animation

I'm converting a program from AS3 to JavaScript and I'm running into a problem. I have a movieclip with 3 different frames, each playing a different animation. I want to switch from one animation state to another like it does in AS3. When I first play the clip, I use:

myMC.on('tick',function(){ this.gotoAndStop(0);} );

and it plays the animation in the first frame perfectly. However, when I use the same code to switch to another frame, such as:

myMC.on('tick',function(){ this.gotoAndStop(1);} );

The animation clip doesn't play - the movie clip stays on the first frame. It's as if the act of switching to one of the other nested movieclips breaks the animation playback. Any ideas? 

    9 replies

    kglad
    Community Expert
    Community Expert
    Mar 10, 2025 2:56 PM UTC

    why are you showing code for two different movieclips?

     

    p.s.  the usual problem is caused by the use of "this"

    Translate
    TheOriginalGC
    Community Expert
    Community Expert
    Mar 10, 2025 3:08 PM UTC

    Human error in posting. Supposed to be the same.

     

    I tried removing 'this' and it caused the whole thing to freeze up when switching to a different animation.

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 10, 2025 3:12 PM UTC

    you can't just remove "this" and expect something to work.  you need to define "this".

    Translate