3 Replies Latest reply on Sep 13, 2010 7:01 AM by kglad

    Stopping an animation once it played?

    JamesCun

      I have 2 frames in an "enemy" movieclip, and frame 1 contains a movieclip with an idle animation, and frame 2 contains a movieclip with a throwing animation. I want it to play the throwing animation, and then go back to the idle animation. But all things I tried always make it loop.


      I tried around with if currentframes = totalframes and gotoAndStop etc but it doesn't want to work. I have my code in an actionscriptfile, however I also tried putting code on frames and it doesn't work.

       

      I'm new to action script, it would be cool if someone could give me a heads up. Thanks

        • 1. Re: Stopping an animation once it played?
          kglad Adobe Community Professional & MVP

          on the last frame of your throwing animation add:

           

          this._parent.gotoAndStop(1);

          • 2. Re: Stopping an animation once it played?
            JamesCun Level 1

            Thank you, that works great!

             

            Another question: I want to spawn an item that the character is throwing, would I spawn this in the last frame of the animation as well, to make sure its spawning only when the last frame plays?

             

            Currently in my onEnterFrame function I have:

             

             

            throwTimer+=1

             

            if throwTimer>10

            {

            throwTimer=0

            gotoAndStop(2);

             

            }

             

            And on the last frame of the throwing animation I have:

             

            var throwItem = _root.attachMovie( "throwItem" , "throwItem" + _root.getNextHighestDepth(), _root.getNextHighestDepth() );

            throwItem._x = _x;

            throwItem._y = _y;

             

            this._parent.gotoAndStop(1);

             

            At first it worked and spawned the item right, but didn't spawn it only when the last frame is reached. After tinkering around a bit I ended up with the code above, however, it ALWAYS spawns in the upper left side, even though I gave it co ords to spawn at. What am I doing wrong?

            • 3. Re: Stopping an animation once it played?
              kglad Adobe Community Professional & MVP

              please mark this thread as answered and start another thread for another issue.