View Full Version : Create instance by name: AS3 equivalent to AS2's new ["Blah"]();?
Aesir
October 8th, 2007, 11:33 PM
I need to be able to create instances of classes by class name, from a String.
In AS2, I could do var a:Array = new ["Array"]();
Is there a new way to do this is AS3? Using the entire file path would also be useful.
Thanks!
McGuffin
October 9th, 2007, 01:03 AM
Here (http://www.kirupa.com/forum/showthread.php?t=277242)
I could point out the advantages of searching, but you've probably heard it before ;)
Sirisian
October 9th, 2007, 01:30 AM
Also if you are interested research factory objects.
http://en.wikipedia.org/wiki/Factory_object
Aesir
October 9th, 2007, 11:51 AM
Solved. Anyone facing the same problem should search:
flash.utils.getDefinitionByName;
flash.utils.getQualifiedClassName;
(I tried to arrive at this answer through Kirupa, but I actually found it after a grueling hike through the help documentation.)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.