Dynamic Class Names

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 .

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

No related posts.

Related Posts

Popular Posts


Leave Your Response

* Name, Email, Comment are Required

Hire Flashmad

Hosting & Domains


Google Live Chat

Call me at

_____________________________ +91 9995040559

Add me on Skype

 - Tinku Tharasing: