Properties of MovieClips

Movie Clips have properties such as x, y, width, height, and rotation that can be changed using ActionScript.

Get Adobe Flash player
  1. Start a new movie.
  2. Draw a star, then make it a movie clip called Star.
  3. Name the instance on the stage (in the properties window) star.
    name the instance
  4. Note: It is very important to name the instance on the stage. The MovieClip in the library is named Star. The instance on the stage is named star.

    It is a good habit to put all of your actionscript in one layer.

  5. Make a new layer and name it actionscript.
  6. Drag the actionscript layer to the top of all the layers:
  7. action script layer

  8. Open the Actions window by right clicking on the time line and selecting Actions, or press F9, or select from the menu Window, Actions.

  9. In the actions window type the code:

Run the movie buy pressing Ctrl+Enter (Command+Return on the Mac)

star running

When the actionscript code is executed, the x property of the star, which is in the middle of the star, is placed against the left edge of the stage.

The x property determines the distance from the left edge. The y property determines the distance down from the top.

Experiment: Modify the code to change both the x and y values to 0. Try other values for x and y.

Debugging: If you program doesn't work make sure that you have named the instance on the stage star. Make sure that is is all lower case. Make sure that your code exactly matches the code shown. If it still doesn't work, download the source movie and compare carefully to find out what you did wrong.

More Properties

There are several more properties that you can change using ActionScript3.

Try each of the commands below, then experiment with varoius combinations of them.
Run the movie each time buy pressing Ctrl+Enter (Command+Return on the Mac)

Sometimes we change the value of a property by adding to its current value:

The last statement moves the star to the right by adding 10 to the current value of star.x.
Another way to write this is:


Changing the current value of a property (incrementing it) is so common that this short cut is used most of the time.
Statements that give a new value to a property are called assignment statements.

NEXT: MovieClips and the Stage