
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
338
|
Chapter 13: Movie Clips
representations of a movie clip identifier (see also the legacy _target property dis-
cussed later in this chapter):
trace(instance1._name); // Displays instance1
trace(instance1); // Displays _level0.instance1
trace(String(instance1)); // Displays _level0.instance1
trace(targetPath(instance1)); // Displays _level0.instance1
trace(instance1.toString( )); // Displays [object Object]
Example 13-1 uses the _name property to find a particular movie clip. See “The _name
property” later in this chapter for an example showing how to use the
_name property
to prevent an infinite loop.
If we change an instance’s
_name property, all future references to the instance must
use the new name. For example, if we change the value of
ball_mc._name, the ball_mc
reference ceases to exist, and we must subsequently use the new name to refer to the
instance:
ball_mc._name = "circle_mc"; // Change ball_mc's name to circle_mc
trace(typeof ball_mc); // Displays "undefined" because ball_mc
// no longer exists.
circle_mc._x = 59; // After the name change, you must
// use the clip's new name.
Therefore, you shouldn’t change a movie clip’s _name property at runtime, as it is can
make your code fail, or at least make it very difficult to follow.
Importing External Movies and Images
We’ve discussed ...