Skip navigation
Currently Being Moderated

Making a MovieClip animation move

May 25, 2012 11:31 PM

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.

 
Replies
  • Currently Being Moderated
    May 26, 2012 4:12 AM   in reply to Formation_2

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 10:53 PM   in reply to Formation_2

    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;

                        }

     

              }

     

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points