Set x,y Coordinates with ActionScript

Start Positions

We're going to control our MovieClips with ActionScript, so add an actions layer at the top of the timeline. All of our ActionScript is going on Frame 1 of the actions layer:

drag

Now bring up the ActionScript dialogue box. Your keyboard shortcut is F9 (or you can Right-Click on Frame 1 in the actions layer and choose actions). Either way, make certain the ActionScript window displays ACTIONS-FRAME:

Copy and Paste the following script into the ActionScript window:

ball1.x=100;

Pay particular attention to the color-coding in the ActionScript window. Notice the x is bright blue. This means x is a reserved name in ActionScript and cannot be used for anything else (For instance, x would make a terrible instance name). By the same token, notice ball1 is displayed as plain black text. That's good! The instance name we chose is not a reserved name:

Now have a look at the Timeline. You should see a little a on Frame 1 of the actions layer, indicating is some ActionScript on that frame:

Test the movie now. You should see that ball1 has moved to the right (x=100 to be exact):

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Remember: this only works when you TEST the movie using CTRL+ENTER