Hey Rick, no need to create an instance, but do create a variable of that type, so the compiler knows to include that class in the package.
var ssc:SomeSweetClass; === Or simply cast to it in your call classRef = getDefinitionByName("com.sweet.SomeSweetClass") as Class; var mySweetness:SomeSweetClass = SomeSweetClass(new classRef()); ============== Alternatively you can use compiler directives that tell flex builder to package that class into the build, but that's annoying ;) GL Seth -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Friday, August 10, 2007 2:37 PM To: [EMAIL PROTECTED]; flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Q: Including class at compile w/o explicitly instantiating it Try just doing: var ssc:SomeSweetClass; On 8/10/07, Rick Terrill <[EMAIL PROTECTED]> wrote: > Hi everyone, it's my first time posting to the board. > > I'm trying to figure something out, or if it's even possible. I would like > to dynamically instantiate a class (via getDefinitionByName) but without > explicitly instantiating the object prior in the class. > > An example (this is what I would like to be able to do): > > package > { > import com.sweet.*; > import flash.utils.getDefinitionByName; > > public class Foo > { > public function Foo() > { > classRef = getDefinitionByName("com.sweet.SomeSweetClass") as > Class; > var mySweetness:Object = new classRef(); > } > } > } > > I figured that the import would take care of it, but it doesn't. I have to > do at least one 'var ssc:SomeSweetClass = new SomeSweetClass();' and then it > will work. If not, then I get a reference error like: > ReferenceError: Error #1065: Variable SomeSweetClass is not defined. > > Is there any way to do this with Run-Time libraries, or some directive or > metadata or something? Or is there something really obvious that I'm > missing? > > t.i.a! > > -- > Rick Terrill > - www.rickterrill.com > - www.linkedin.com/in/rickterrill > _______________________________________________ > 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 _______________________________________________ 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