![MACROMEDIA FLASH MX 2004-LEARNING FLASH Скачать руководство пользователя страница 101](http://html1.mh-extra.com/html/macromedia/flash-mx-2004-learning-flash/flash-mx-2004-learning-flash_manual_3379009101.webp)
Play a movie clip
101
Play a movie clip
You can configure your document to play a movie clip at runtime. Using the
attachMovie()
method, you can attach an instance of a movie clip in the Library panel to the Stage even though
you have not placed an instance on the Stage.
With the
attachMovie()
method, you must export the symbol for ActionScript and assign it a
unique linkage identifier, which is different from the instance name.
1.
In the Library panel, right-click the MCTrio symbol and select Linkage from the context menu.
2.
In the Linkage Properties dialog box, select Export for ActionScript.
3.
In the Identifier text box, verify that MCTrio appears as the linkage name.
4.
Verify that Export in First Frame is selected, and then click OK.
Movie clips that are exported for use with ActionScript load, by default, before the first frame
of the SWF file that contains them. This can create a delay before the first frame plays. When
you assign a linkage identifier to an element, you can specify that the movie clip load on the
first frame to avoid playback delays.
Use the attachMovie() method to play a movie clip
You’ll now use the
attachMovie()
method to load the movie clip and provide the symbol with
an instance name. Since the instance of the symbol does not exist on the Stage, you’ll create the
instance name programmatically.
1.
In the Timeline, select Frame 1 of the Actions layer for Scene 1.
2.
In the Script pane of the Actions panel, place the insertion point at the end of your last line of
code. Press Enter or Return, and then type the following to add a comment and create a
new function:
//function plays trio_mc when attachMovie_btn instance is released.
attachMovie_btn.onRelease = function(){
Next, you’ll specify what the function does: it plays the movie clip on the root Timeline, which
is the main Timeline. In your script, you’ll refer to the movie clip by the linkage identifier
name in the Linkage Properties dialog box (MCTrio).
Additionally, even though you didn’t place an instance of the MCTrio symbol on the Stage,
you’ll use ActionScript to create an instance name for the symbol. The instance name that
you’ll specify is trio_mc.
3.
With the insertion point at the end of the last line of script, press Enter or Return. Then type
the following:
_root.attachMovie("MCTrio", "trio_mc", 1);
The number 1 in the script that you just typed refers to the depth on the layer in which to play
the movie clip.
Every movie clip instance has its own
z
axis (depth) that determines the stacking order of a
movie clip within its parent SWF file or movie clip. When you create a new movie clip at
runtime using the
attachMovie()
method, you always specify a depth for the new clip as a
method parameter.
Содержание FLASH MX 2004-LEARNING FLASH
Страница 1: ...Learning Flash...
Страница 8: ...8 Contents...
Страница 34: ...34 Chapter 3 Write Scripts with ActionScript...
Страница 54: ...54 Chapter 6 Create a User Interface with Layout Tools...
Страница 62: ...62 Chapter 7 Draw in Flash...
Страница 68: ...68 Chapter 8 Create Symbols and Instances...
Страница 76: ...76 Chapter 9 Add Animation and Navigation to Buttons...
Страница 104: ...104 Chapter 13 Add Interactivity with ActionScript...
Страница 112: ...112 Chapter 14 Create a Form with Conditional Logic and Send Data...
Страница 122: ...122 Chapter 15 Work with Objects and Classes Using ActionScript 2 0...