On 01.13.11, In Actionscript 3.0, by admin
Today i found something interesting from an e book about Action Script . I was in need of this feature long back on a project but i thought its impossible with AS 3.0 . Its about using dynamic class names in loops to make easy class object creation . The code sample given below. This stuff will be useful when you give linkage to your library items with numeric names at end.
for (var i:uint = 1; i < = 10; i + + ) {
var boxClass:Class = getDefinitionByName( myBox + i) as Class;
var box:myBox = new boxClass();
addChild(box);
}
getDefinitionByName comes under flash.utils package .
No related posts.






Leave Your Response