Are you sure you're embedding the code for the objects into your app?

import com.mypack.MyClass;

on its own isn't enough: you need a concrete reference to a class for
its code to be included in the SWF.

Something like:

import com.mypack.MyClass;
import com.mypack.MyOtherClass;

// somewhere in the startup of your app
var dummyClasses:Array=[MyClass,MyOtherClass];

should be enough to get them compiled in.

HTH,
   Ian

On Fri, Apr 4, 2008 at 1:18 PM, Jiri Heitlager
<[EMAIL PROTECTED]> wrote:
> Thanx Ian,
>
>  it is still tracing null. Is this even possible to do. How do all the big
> boys do dynamic instantation. What I basically want to achieve is
>  have a hashMap store different kinds of Command Objects. Instead of
> instantiation at the start of the app, I would like to instatiated them when
> the are required. The argument thing I can probably solve by adding a method
> to the CommandObject  interface like addParameters() The type casting is the
> real problem here. I cant have the commands tracing as null..
>
>  Do you or anybody maybe have a solution?
>
>  Jiri
>
>
>
>  Ian Thomas wrote:
>
> > On a quick glance, I think this line is breaking it:
> >
> > var constructor:Function = Function( _global );
> >
> > because _global is not a function.
> >
> > Try:
> >
> > function createInstance ( classPath:String , args:Array) : Object
> >  {
> >       var packageList:Array = classPath.split( "." );
> >       var constructor:Object =  _global ;
> >
> >       while( packageList.length> 0 )
> >       {
> >           constructor = constructor[String(packageList.shift() )];
> >       }
> >
> >       return Function(constructor).apply( constructor , args ) ;
> >   }
> >
> > On Fri, Apr 4, 2008 at 12:29 PM, Jiri Heitlager
> > <[EMAIL PROTECTED]> wrote:
> >
> > > Hello list,
> > >
> > >  Does anybody know an AS2 version of the AS method getDefinitionByName()
> > >  I would like to dynamic instantiated classes in AS2 with passing
> argument
> > > to that created instance.
> > >
> > >  I am using a modified script from  'http://blog.generalrelativity.org/'
> ,
> > > but the return datatype  ==  null, even when I cast the returned
> instance.
> > >
> > >
> > >  import test.Shape
> > >
> > >
> > >  function createInstance ( classPath:String , args:Array) : Object
> > >    {
> > >        var packageList:Array = classPath.split( "." );
> > >
> > >        var constructor:Function = Function( _global );
> > >
> > >
> > >        while( packageList.length> 0 )
> > >        {
> > >            constructor = constructor[ String( packageList.shift() ) ];
> > >
> > >        }
> > >
> > >                return constructor.apply( constructor , args ) ;
> > >
> > >    }
> > >
> > >  var newShape:Shape = Shape ( createInstance('test.Shape' , [1,2,3]) )
> > >
> > >  trace( newShape ) //ouputs null, it should output Shape
> > >
> > >
> > >
> > >
> > >  _______________________________________________
> > >  Flashcoders mailing list
> > >  [email protected]
> > >  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > >
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
>  _______________________________________________
>  Flashcoders mailing list
>  [email protected]
>  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to