classactionscript-3addchild

Using same class name but adding different mc dynamically


I have three movieClips are mc1, mc2 and mc3. It is simple to add a movie clip from library dynamically with its class name. This method requares different class names for all movieClips that I want to add. The problem is "control.as" file. I need to define a same class name to control all atached movie with the same "control.as" file. How can I define same class name as "control" and then I can add them dynamically?

for(var i=1;i<=3;i++){
   var parameter="mc"+i
   ...?
   ...?
   ...?
}

Solution

  • Set control.as as the base class of the individual library symbols and give each one a unique class name.

    This way they all share the behavior of the base class but can be uniquely identified and added to the display list by their class name.