You name instances using an instance name, which you can specify in two different ways (both
demonstrated below):
Manually by selecting an instance and typing an instance name in the Property inspector
(when an instance is on the Stage).
Dynamically by using ActionScript. You create an instance using ActionScript and assign
it an instance name when you create it.
To assign the instance an instance name in the Property inspector, type a name into the
Instance Name text box.
You can also give an instance name to an object you create using ActionScript. It can be as
simple as the following code:
this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth());
pic_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
This code creates a new movie clip and assigns it the instance name pic_mc. Then, you can
manipulate the
pic_mc
in the previous code.
For more information on working with scope, see
and
"About variables and scope" on page
Targeting an instance
If you want something to work in your SWF file, you need to target that instance and then
tell it to do something, such as assigning it an action or changing its properties. You usually
need to define where that instance is in the SWF file (for example, what timeline it's on or
what instance it's nested within) by creating the target path. Remember that you have given
many of the instances in your FLA file instance names, and then you added code to the FLA
file that uses those instance names. When you do this, you target that particular instance and
then tell it to do something (such as move the playhead or open a web page). For more
information on objects and properties, see
To target an instance:
1.
Select File > New and select Flash Document.
2.
Select File > Save As and name the file target.fla.
3.
Use the Oval tool to draw a shape on the Stage. Draw an oval of any size and color.
4.
Use the Selection tool to select the oval on the Stage.
Remember to select the stroke and fill if necessary.
instance using code, such as loading an image into it as demonstrated
96.
"Object data type" on page
"About scope and targeting" on page 123
78.
About dot syntax and target paths
119
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?