A tutorial showing you how to move a movieclip using Flash C3 (or higher) Actionscript 3
Step 1.
Before we start to write the actionscript 3 code, we need to import (File > Import > Import to Stage) an image into Flash (CS3 or higher). If you like you can save image a) below and import it, or use one of you own.
a)
b)
Step 2.
Once it's on the stage, click on it and convert it (Modify > Convert to Symbol) to a Movie Clip Symbol. Click on the "advanced" button.
Click "export for actionscript". This will fill in the "class" section with the same name as the MC, and fill in the base class , as shown below. I've changed the class name to "square".
Step 3.
You will get a warning message, such as the one below. This is because we havent created an external class called "square". But just click ok, because an external class isn't needed to simply attach movie clips to the stage.
Step 4.
Now that the graphic is now contained in a movie clip symbol, you can now delete it, since we will now be writing the code to attach it dynaically
Step 5.
Here we are creating an instance of the square movie clip and naming it "small_square".
Line 1: Create an instance of square called square_mc
Line 2: Add small_square as a child
Line 3: Position playerMc along the x axis
Step 6.
Line 5: A variable is created for the speed of movement
Line 6: An event listener is created. The type is set to ENTER_FRAME and the function to is set to move_square. Using ENTER_FRAME will run the move_square function repeatedly at the frame rate of the movie.
Line 7-9: The move_square function is created, which simply makes the small_square movie clip move 2 pixels (speed) everytime it is called.