EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Specifying an Objects Path

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
50 Chapter 2: ActionScript Basics
You create multidimensional arrays in ActionScript by constructing an array, the elements of
which are also arrays. To access elements of a multidimensional array, you can nest the array access
operator with itself, as shown in the following example:
var chessboard = new Array();
for (var i=0; i<8; i++) {
chessboard.push(new Array(8));
}
function getContentsOfSquare(row, column){
chessboard[row][column];
}
You can check for matching [] operators in your scripts; see “Checking syntax and punctuation
on page 66.
Specifying an object’s path
To use an action to control a movie clip or loaded SWF file, you must specify its name and its
address, called a target path.
In ActionScript, you identify a movie clip by its instance name. For example, in the following
statement, the
_alpha property of the movie clip named star is set to 50% visibility:
star._alpha = 50;
To give a movie clip an instance name:
1 Select the movie clip on the Stage.
2 Enter an instance name in the Property inspector.
To identify a loaded SWF file:
Use _levelX, where X is the level number specified in the loadMovie() action that loaded the
SWF file.
For example, a SWF file loaded into level 5 has the target path
_level5. In the following
example, a SWF file is loaded into level 5 and its visibility is set to
false:
onClipEvent(load) {
loadMovieNum("myMovie.swf", 5);
}
onClipEvent(enterFrame) {
_level5._visible = false;
}
To enter a SWF file’s target path:
In the Actions panel (Window > Development > Actions), click the Insert Target Path button
and select a movie clip from the list that appears.
For more information on target paths, see “Absolute and relative target paths” in Using
Flash Help.

Table of Contents

Related product manuals