Hello :)

in AS3 to instanciate an object with only this class name (String) you can
use the flash.utils.getDefinitionByName() method :

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getDefinitionByName()

EKA+ :)


2007/7/26, JOR <[EMAIL PROTECTED]>:

How about using the abstract factory design pattern?

public class MyFactory {
   public static function createObject(objType:String):* {
     switch (objType) {
       case "Foo":
         return new Foo();
       case "Bar":
         return new Bar();
       default:
         return new Foo();
   }
}

var myObj:* = MyFactory.createObject("Foo");


James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



Matt Muller wrote:
> Hi, I'm trying to instantiate a new class object from a xml attribute
which
> is a string, but its not having any of it.
> I've tried casting the string to an object and also using
this['class_id']
> etc but no luck.
>
> Does someone have a solution?
>
> Thanks,
>
> MaTT
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to