Skip to main content
May 26, 2012
Question

Making a MovieClip animation move

  • May 26, 2012
  • 2 replies
  • 742 views

So I have this chicken animated in a movieclip and when I place it on the stage, it just sits there playing the animation but doesn't move around.  I just want it to walk around on the stage when the animation is playing.  I don't want this to be controlled by arrow keys or anything and I'm using AS3 btw.

This topic has been closed for replies.

2 replies

May 29, 2012

package

{

          import flash.display.MovieClip;

          import flash.events.Event;

          import flash.events.MouseEvent;

 

          /**

           * ...

           * @author Vipul Khandelwal

           */

          public class demo extends MovieClip

          {

                    private var obj:MovieClip;

 

                    public function demo()

                    {

                              obj = new MovieClip();

                              obj.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

                    }

 

                    private function enterFrameHandler(e:Event):void

                    {

                              // if you want to move x, use this.

                              obj.x += 5;

 

                              // if you want to move y, use this.

                              obj.y += 5;

                    }

 

          }

 

}

Ned Murphy
Legend
May 26, 2012

If you want it to constantly be moving around, then look into using an Event.ENTER_FRAME listener with an event handler function that is incrementally changing the position properties (x and/or y) that represent the direction(s) in which you wish the movieclip to move.