Archived:How to attach symbols dynamically in ActionScript 2.0
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
Article Metadata
Introduction on Symbols and MovieClips
Attaching symbols dynamically to frames is a quite simple and useful task in developing Flash Lite applications using ActionScript 2.0. In this post I'll teach you how to create a new symbol (MovieClip or Button) which can be exported to the wished frame by AS 2.0.
Procedure
- Step 1: Create a rectangle or whatever drawing you wish.
- Step 2: Convert it to a symbol (MovieClip or Button) as shown below:
- Step 3: In the dialog box set the configurations as shown the the picture below, It's extreamly important check the "Export for ActionScript" option:
Name: Instance type name of the symbol; Type: Symbol type, how it will behave. Identifier: Identifier that will be used to attach the newly created symbol to the frame using AS 2.0.
Click OK to finish the symbol creation.
- Step 4: In the action of the frame which you want to attach the symbol type the following code:
var s1 = attachMovie("my_symbol", "symbol_01", 1);
That way you will have a button with name "symbol_01" in depth "1", as default it will be attached in the (0, 0) position; nevertheless you can put it whatever position you want, only see the code below:
var s1 = attachMovie("my_symbol", "symbol_01", 1);
s1._x = 50;
s1._y = 50;
Note: You can attach as many button as you want, but you will have to set a different value in the third parameter (depth) of the "attachMovie" function for each of the symbol you want to.
- More: To attach a MovieClip just do the same steps describled above, just set MovieClip to the Type field in the dialog box in the 'step 3'.
Tip: MovieClips can be positioned only giving the following params to the "attachMovie" function:hMovie”:
var s1 = attachMovie("my_symbol", "symbol_01", 1, {_x: 50, _y: 50});


Manellen - Add Images
Hi,
Does anyone know how to add or load image into our button symbol?
I have succeed to load image dynamically from xml file into movieClip symbol but it's difficult when we load image into button symbol. Please give me direction.
Here is my script to load image into movieClip symbol:
for (i = 0; i < _global.totalMovie; i++)
{
_root.createEmptyMovieClip("myMC_"+i, i);
eval("myMC_"+i)._x = i * thumbX + 150;
eval("myMC_"+i)._y = thumbY;
eval("myMC_"+i).loadMovie(movieImages[i]);
}
manellen 04:54, 20 March 2012 (EET)