Imagine I have in my library a series of MovieClips with linkage identifiers
like so:

sym0
sym1
sym2
...
sym29

In AS2, if I wanted to create instances of each one (or perhaps decide which
symbol to use based on XML data, for example), I could use a for loop:

for (var i:Number = 0; i < 30; i ++) {
    var new_mc:MovieClip = parent_mc.attachMovie("sym" + i, "sym" + i, i);
    // do stuff with clip
}

and create each symbol via passing a concatenated string as symbolName.

Now, in AS3, I can't think of a way to do this efficiently. In our simple
example, I can only think of the following:

for (var i:int = 0; i < 30; i ++) {
var sym:MovieClip;
     switch (i) {
         case 0: sym = new sym0();
         case 1: new sym1();
         case 2: new sym2();
...
     }
    // do stuff with clip
}


Is there a more efficient way to do this in AS3? You can't really
instantiate a class based on a stringname, can you?


-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to