MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 121

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

If you work with nested movie clips that have their own timelines, you can manipulate the
playhead in a nested instance's timeline using code similar to the following snippet:
myClip.nestedClip.gotoAndPlay(15);
myClip.someOtherClip.gotoAndStop("tweenIn");
Notice that the clip that you manipulate (such as
action. You'll notice this trend in upcoming sections.
You aren't limited to accessing predefined methods and properties of instances on the Stage, as
demonstrated in the previous examples. You can also set a variable within a movie clip, as seen
in the following code, which sets a variable in the starClip movie clip:
starClip.speed = 1.1;
starClip.gravity = 0.8;
If either the speed or gravity variables existed previously in the starClip movie clip instance,
the previous values would have been overwritten as soon as the new values were set. You are
able to add new properties to the starClip movie clip, because the MovieClip class was defined
with the
keyword. The
dynamic
specified class (in this case MovieClip) can add and access dynamic properties at runtime. For
more information about the dynamic statement, see dynamic statement in the
ActionScript 2.0 Language Reference.
Targeting dynamic instances and loaded content
You can also create an object using ActionScript and target it using a target path afterwards.
For example, you can use the following ActionScript to create a movie clip. Then you can
change the rotation of that movie clip using ActionScript, as shown in the next example:
To target a dynamically created movie clip instance:
1.
Create a new Flash document and save the file as targetClip.fla.
2.
Insert a new layer and rename the layer actions.
3.
Add the following ActionScript to Frame 1 of the actions layer:
this.createEmptyMovieClip("rotateClip", this.getNextHighestDepth());
trace(rotateClip);
rotateClip._rotation = 50;
4.
Select Control > Test Movie to test your document.
You can tell that you created a movie clip because of the
see anything on the Stage. Even though you added code that creates a movie clip instance,
you won't see anything on the Stage unless you add something to the movie clip. For
example, you might load an image into the movie clip.
5.
Return to the authoring environment, and open the Actions panel.
nestedClip
keyword specifies that objects based on the
dynamic
) appears right before the
statement, but you cannot
trace
About dot syntax and target paths
121

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents