Board logo

subject: Controlling Movie Clip Properties with ActionScript 3.0 [print this page]


Controlling Movie Clip Properties with ActionScript 3.0

Most Flash designers are used to working with movie clip symbols in the Flash interface. But nearly all the features that can be accomplished with movie clips in the Flash interface can also be controlled with ActionScript. You can even create new movie clips from scratch with ActionScriptvideo tutorials. This article shows how to change some basic MovieClip properties with ActionScript.

NOTE

This article is adapted from ActionScript 3.0 for Adobe Flash CS4 Professional Classroom in a Book. Copyright 2009. Used with permission of Pearson Education, Inc. and Adobe Pressvideo tutorials.

Changing a Property Value

The basic syntax to change any property of a MovieClip is to type the clip's instance name, followed by a period (.), the property name that you want to change, an equals sign (=), and then the new value:

movieClipInstanceName.propertyName = value;

For example, if you have a MovieClip with an instance name of clip1 and you want to rotate it 90 degrees, the code would read this way:

Clip1.rotation = 90;

If you know the possible properties that you can control and their range of values, this simple technique can accomplish quite a bit.

The following table contains a few of the most common properties and their ranges. For the full range of properties and values, see Flash CS4 Helpvideo tutorials.

Property

Values

Description

x

infinity to +infinity

Horizontal position

y

infinity to +infinity

Vertical position

rotation

180 to 180 (degrees)

Rotation

alpha

0 to 1 (0 = transparent, 1 = opaque)

Transparency

scaleX

infinity to +infinity

Horizontal scale

scaleY

infinity to +infinity

Vertical scale

visible

true (visible) or false (invisible)

Visibility

NOTE

For the rotation property, you can use any numbers, but ActionScript will convert them to the range between 180 and +180 degrees.

The Flash stage is measured from the upper-left corner. A movie clip with an x position of 0 means that the registration point of the clip is on the exact left of the stage. A position of 0 for the y value means that the clip is at the top of the stage. Values greater than zero for x and y refer to positions to the right and down, respectively. Negative x and y values indicate positions offstage to the left and above the stage.




welcome to loan (http://www.yloan.com/) Powered by Discuz! 5.5.0