About controlling movie clips with ActionScript
353
In the first statement,
play()
moves the playhead in the
myMovieClip
instance. In the
second statement,
gotoAndPlay()
sends the playhead in
childClip
(which is a child of the
instance
parentClip
) to Frame 3 and continues to move the playhead.
Global functions that control a timeline have a
target
parameter that let you specify the
target path to the instance that you want to control. For example, in the following script
startDrag()
targets the instance the code is placed on and makes it draggable:
my_mc.onPress = function() {
startDrag(this);
};
my_mc.onRelease = function() {
stopDrag();
};
The following functions target movie clips:
loadMovie()
,
unloadMovie()
,
loadVariables()
,
setProperty()
,
startDrag()
,
duplicateMovieClip()
, and
removeMovieClip()
. To use these functions, you must enter a target path for the function’s
target
parameter to indicate the target of the function.
The following MovieClip methods can control movie clips or loaded levels and do not have
equivalent functions:
MovieClip.attachMovie()
,
MovieClip.createEmptyMovieClip()
,
MovieClip.createTextField()
,
MovieClip.getBounds()
,
MovieClip.getBytesLoaded()
,
MovieClip.getBytesTotal()
,
MovieClip.getDepth()
,
MovieClip.getInstanceAtDepth()
,
MovieClip.getNextHighestDepth()
,
MovieClip.globalToLocal()
,
MovieClip.localToGlobal()
,
MovieClip.hitTest()
,
MovieClip.setMask()
,
MovieClip.swapDepths()
.
For more information about these functions and methods, see their entries in the
ActionScript
2.0 Language Reference
.
For an example of scripted animation in Flash, you can find a sample source file,
animation.fla, in the Samples folder on your hard disk.
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Animation.
■
On the Macintosh, browse to
Macintosh HD
/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Animation.
Содержание 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...