MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 214

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

To populate a dynamically created movie clip with parameters from a specified object:
Do one of the following:
Use the following syntax with
myMovieClip.attachMovie(idName, newName, depth [, initObject])
Use the following syntax with
myMovieClip.duplicateMovie(idName, newName, depth [, initObject])
The
initObject
populate the dynamically created movie clip.
To populate a movie clip with parameters by using attachMovie():
In a new Flash document, create a movie clip symbol by selecting Insert > New Symbol. Type
1.
in the Symbol Name text box, and select the Movie Clip behavior.
dynamic_mc
Inside the symbol, create a dynamic text field on the Stage with an instance name of name_txt.
2.
Make sure this text field is below and to the right of the registration point.
Select the first frame of the movie clip's Timeline, and open the Actions panel (Window >
3.
Development Panels > Actions).
Create a new variable called
4.
shown in the following example:
var name:String;
name_txt.text = name;
Select Edit > Edit Document to return to the main Timeline.
5.
Select the movie clip symbol in the library, and select Linkage from the Library options menu.
6.
The Linkage Properties dialog box appears.
Select the Export for ActionScript option, and click OK.
7.
Select the first frame of the main Timeline, and add the following code to the Actions panel's
8.
Script pane:
/* Attaches a new clip called Erick and
moves it to an x and y coordinate of 50 */
this.attachMovie("dynamic_mc", "newClip_mc", 99, {name:"Erick", _x:50,
_y:50});
Test the movie (Control > Test Movie). The name you specified in the
9.
appears inside the new movie clip's text field.
214
Chapter 8: Working with Movie Clips
attachMovie()
duplicateMovie()
parameter specifies the name of the object whose parameters you want to use to
, and assign its value to the
name
:
:
property of
text
, as
name_txt
call
attachMovie()

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT 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 mx 2004 - actionscript

Table of Contents