Revision as of 08:59, 3 October 2012 by hamishwillee (Talk | contribs)

Archived:How to attach symbols dynamically in ActionScript 2.0

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: cristovaodoj (12 Mar 2010)
Last edited: hamishwillee (03 Oct 2012)

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.


  • 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.pngNote: 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.pngTip: 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});
118 page views in the last 30 days.