Learning Flash Lite 1.x ActionScript |
|
|
|
| Flash 4 ActionScript Primer > Getting and setting movie clip properties | |||
To get or set a movie clip property (if settable), you can use dot syntax or the setProperty() or getProperty() functions. You can also use the tellTarget() function.
To use dot syntax, specify the movie clip instance name, followed by a dot (.) and then the property name. For example, the following code gets the x screen coordinate (represented by the _x movie clip property) of the movie clip named cartoonArea, and assigns the result to a variable named x_pos.
x_pos = cartoonArea._x;
The following example is equivalent to the previous example, but uses the getProperty() function to retrieve the movie clip's x position:
x_pos = getProperty(cartoonArea, _x);
The setProperty() function lets you set a property of a movie clip instance, as shown in the following example:
setProperty(cartoonArea, _x, 100);
The following example is equivalent to the previous example but uses dot syntax:
cartoonArea._x = 100;
You can also get or set movie clip properties from within a tellTarget() statement. The following code is equivalent to the setProperty() example shown previously:
tellTarget("/cartoonArea") {
_x = 100;
}
For more information about the tellTarget() function, see Controlling other timelines.
|
|
|
|