But using getDefinitionByName, can you find a class that's inside a loaded swf?
Like in this example, Test is a class inside test.swf but I get an Error #1065: 
Variable Test is not defined. But it works fine if I call getDefinitionByName 
from within test.swf

public function GetDefinitionByNameExample() {
        var request:URLRequest = new URLRequest("test.swf");
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeEvent);
        loader.load(request);
}

private function completeEvent(e:Event):void{
        trace("completeEvent");
        var ClassReference:Class = getDefinitionByName("Test") as Class;
        var instance:Object = new ClassReference();
}



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Kremens
Sent: Monday, June 18, 2007 1:52 PM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] AS3 new Class from string

There's also this:

var ClassRef:Object = getDefinitionByName("flash.display::Sprite");
var element:Sprite = new ClassRef();

That allows you to really use a string and not a class reference,
which is what I think you want...

But, as with Flash 8, the class reference must really exist in your
swf somewhere, so
you may as well do what elibol suggested...

Jim Kremens
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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