About dot syntax and target paths
119
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
instance using code, such as loading an image into it as demonstrated
in the previous code.
For more information on working with scope, see
“About scope and targeting” on page 123
and
“About variables and scope” on page 96
.
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
“Object data type” on page 78
.
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.
TI
P
Remember to select the stroke and fill if necessary.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...