Steven Sacks wrote:
If you do not do anything with an imported class, Flash will not compile it.

Or, to take it a step further, make a class named ClassRegistry (or some such), which defines but does not instantiate private static instances of every class you want to load dynamically. Then just define one instance of that registry in each class that will do dynamic instantiation.

class ColorRegistry
{
   // all extend Color
   private static var purple:Purple;
   private static var blue:Blue;
   private static var green:Green;
}

class ColorLoader
{
   private var registry:ColorRegistry;
public function loadColor(className:String):Color
   {
      ClassLoader.getInstance(className);
   }
}

Every class which has an instance defined in ColorRegistry will be available for instantiation. It's a bit of a hassle when you're accustomed to stuff like Java's Class.forName(className) method, but it could be worse.

_______________________________________________
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