Solutions

Got a problem? Let's find a solution.

Home
Portfolio
Where In The World
Blog
Solutions
Resume

Sometimes in flash you need a movie clip to dynamically attach when another action takes place (for example, when a button is clicked). This concept is really easy and is demonstrated in the example below. Download the source file here.

Clicking on the attach button dynamically attaches a movie clip called "dynAtt" from the movie's library. The remove button removes the dynamically attached MC.
In order for this to work, right click the symbol in the library and select "Linkage" from the drop down list. Select "Export for ActionScript" and give the symbol an identifier.

The code to attach and remove the dynamic movie clip is placed on the actions layer and references the button instances (in this case, the buttons are named "attach" and "remove").

The first parameter of the attachMovie command is the linkage name (from the dialog box above), the second parameter is an instance name you assign in this line of code, and the third parameter is the depth the movieclip is assigned.

Like I said, there's nothing to this one, simple as pie.