612
Chapter 7: ActionScript for Flash
Example
The following example logs the reference to a movie clip and its relationship to the main
Timeline. Create a movie clip with the instance name
my_mc
, and add it to the main Timeline.
Add the following ActionScript to your FLA or AS file:
my_mc.onRelease = function() {
trace("You clicked the movie clip: "+this);
trace("The parent of "+this._name+" is: "+this._parent);
}
When you click the movie clip, the following information writes to the log file.
You clicked the movie clip: _level0.my_mc
The parent of my_mc is: _level0
See also
_root
,
targetPath()
,
TextField._parent
MovieClip.play()
Availability
Flash Player 5.
Usage
my_mc
.play()
: Void
Parameters
None.
Returns
Nothing.
Description
Method; moves the playhead in the Timeline of the movie clip.
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Example
Use the following ActionScript to play the main Timeline of a SWF file. This ActionScript is for
a movie clip button called
my_mc
on the main Timeline:
stop();
my_mc.onRelease = function() {
this._parent.play();
};
Use the following ActionScript to play the Timeline of a movie clip in a SWF file. This
ActionScript is for a button called
my_btn
on the main Timeline that plays a movie clip called
animation_mc
:
animation_mc.stop();
my_btn.onRelease = function(){
animation_mc.play();
};
Summary of Contents for FLEX
Page 1: ...Flex ActionScript Language Reference ...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0 ...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally ...
Page 135: ...case 135 See also break default strict equality switch ...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while ...
Page 808: ...808 Chapter 7 ActionScript for Flash ...
Page 810: ...810 Appendix A Deprecated Flash 4 operators ...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code ...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values ...
Page 822: ...822 Index ...