Home / Articles / Adobe Flash / Controlling Movie Clip Properties with ActionScript 3.0

Controlling Movie Clip Properties with ActionScript 3.0

Article Description

By using ActionScript in addition to or instead of the Flash interface, you can create many more interactive possibilities in your Flash projects. The Adobe Creative Team shows how easy it is to use ActionScript to control the properties of a movie clip.

Changing Position

The following procedure shows how to change the horizontal position of a MovieClip called star_mc, which displays a simple five-pointed star:

  1. With the timeline and Actions panel both visible, select frame 1 of the actions layer.
  2. Click the insertion point inside the Actions panel and then type the following code:
    star_mc.x = 275;
  3. Test the movie. The star clip should appear in the horizontal center of the stage.
  4. Now let's change a few other properties of the star.
  5. Add the following lines below the code inserted in step 2:
    star_mc.rotation = 90;
    star_mc.alpha = .5;
  6. Test the movie. The star should appear rotated and 50% transparent.

    Transparency—and most values that are measured in percentages—usually ranges between 0 and 1 in ActionScript 3.0, rather than 0 to 100. The scaleX and scaleY properties follow this rule: A scale value of 1 means that the object is set to 100% of its original size; a scale value of 2 is 200% (twice the size) and a value of .5 is 50% (half the original size).

3. Increasing or Decreasing a Property's Value | Next Section Previous Section