EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Adding Parameters to Dynamically Created Movie Clips

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
364 Working with Movie Clips
For more information, see attachMovie (MovieClip.attachMovie method) in the
ActionScript 2.0 Language Reference.
Adding parameters to dynamically
created movie clips
When you use MovieClip.attachMovie() and MovieClip.duplicateMovie() to create or
duplicate a movie clip dynamically, you can populate the movie clip with parameters from
another object. The
initObject parameter of attachMovie() and duplicateMovie()
allows dynamically created movie clips to receive clip parameters.
For more information, see attachMovie (MovieClip.attachMovie method) and
duplicateMovieClip (MovieClip.duplicateMovieClip method) in the
ActionScript 2.0 Language Reference.
To populate a dynamically created movie clip with parameters from a specified
object:
Do one of the following:
Use the following syntax with attachMovie():
myMovieClip.attachMovie(idName, newName, depth [, initObject]);
Use the following syntax with duplicateMovie():
myMovieClip.duplicateMovie(idName, newName, depth [, initObject]);
The initObject parameter specifies the name of the object whose parameters you want to
use to populate the dynamically created movie clip.
To populate a movie clip with parameters by using attachMovie():
1. In a new Flash document, create a movie clip symbol by selecting Insert > New Symbol.
2. Type dynamic_mc in the Symbol Name text box, and select the Movie Clip behavior.
3. Inside the symbol, create a dynamic text field on the Stage with an instance name of
name_txt.
Make sure this text field is below and to the right of the registration point.
4. Select Frame 1 of the movie clip’s Timeline, and open the Actions panel (Window >
Actions).
5. Create a new variable called name_str, and assign its value to the text property of
name_txt, as shown in the following example:
var name_str:String;
name_txt.text = name_str;

Table of Contents

Related product manuals