But either way, do you still need to force to compiler to add the class? I am almost sure you do, but asking just in case.

Jiri

Hans Wichman wrote:
btw new eval("_global.myPackage.MyClass")(); does the trick as well.
If you please add
Assert.assertNotNull (eval("_global.myPackage.MyClass"))
etc

On Fri, Apr 4, 2008 at 5:01 PM, Jiri Heitlager
<[EMAIL PROTECTED]> wrote:
Thanx Alan, using a custom error exception is a nice little added touch :)

Jiri



Alan MacDougall wrote:
Here is the class I use for dynamic instantiation. Note that it throws a
custom exception type, you'll have to create that type yourself or alter
that line of code. I copied the instantiation technique from Drew Cummins at
blog.generalrelativity.org.
class com.phoenixgp.common.utils.ClassLoader
{
  /* CLASS METHODS */
  /**
      <p>Returns a new instance of a class given the fully-qualified name
of
      the class. The instance will be returned as an <code>Object</code>,
so
      the caller must cast the return value to the expected type or
supertype.</p>
            <p>Original author: Drew Cummins,
blog.generalrelativity.org</p>
            @param classPath The fully-qualified class name, in dot
notation
      @return A new instance of the named class, using its default
constructor
      @throws ClassNotFoundException if the named class is not present.
This
              may indicate an error or omission in the
<code>ClassRegistry</code>.
  */
  public static function createInstance(classPath:String):Object
  {
      var packageList:Array = classPath.split(".");
      var constructor:Function = Function(_global);
            while (packageList.length > 0)
      {
          constructor = constructor[String(packageList.shift())];
      }
            if (constructor == null)
      {
          throw new ClassNotFoundException(classPath);
          return null;
      }
            return new constructor();
  }
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to