Another related question -  now that we can instance a class specified in an
XML document, how can
we dynamically associate this class with a MovieClip instance? It is my
understaning that Object.Register
class associates a class with a movieclip symbol (not an instance).

Thanks,

August

On 1/4/06, August Gresens <[EMAIL PROTECTED]> wrote:
>
> ClassFactory - just what we were looking for. Thanks, August
>
> On 1/4/06, Jim Kremens <[EMAIL PROTECTED]> wrote:
> >
> > Or this:
> >
> > class ClassFactory {
> >
> > public static function getClass(name:String, args:Object):Object {
> >    return new Function(eval(name))(args ? args : []);
> > }
> > }
> >
> > /* USAGE
> > * //can be any referenced class
> > * var myClass = ClassFactory.getClass("
> > org.flashcodersny.style.GradientFill",
> > args);
> > */
> >
> > As long as the class you're trying to instantiate exists in the _global
> > namespace, the above will work.  To make sure it exists, just say its
> > name:
> >
> > class DeclareClassNames {
> >
> >   function DeclareClassNames() {
> >      org.myClass1;
> >      org.myClass2;
> >      //and so on...
> >   }
> > }
> >
> > There have been a few threads on this subject recently...
> >
> > Jim Kremens
> >
> >
> >
> > On 1/4/06, Johannes Nel < [EMAIL PROTECTED]> wrote:
> > >
> > > no it needs to be a ref to the constructer function.
> > > this can be solved however with this:
> > > Object.RegisterClass("myClipSymbolName",
> > > _global["com"]["blackhammer"]["test"]["TestClass"]);
> > >
> > >
> > > On 1/4/06, August Gresens <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello
> > > >
> > > > We're new to flash, migrating over from Director. We're trying to
> > > > implement
> > > > a Java style class loader in Flash, but we are having some
> > difficulty
> > > > doing
> > > > this.
> > > >
> > > > This is what we  are trying to do:
> > > >
> > > > 1. Create an XML document with elements specifying the name of the
> > > class,
> > > > a
> > > > movieclip instance and and some initialization parameters.
> > > >
> > > > for example:
> > > >
> > > > <object class="com.blackhammer.test.TestClass"
> > name="testClassInstance1"
> > > > clipName="myTestClip">
> > > > <param name="param1" value="1" type="int"/>
> > > > </object>
> > > >
> > > > 2. On startup, the Flash movie parses the XML file, instancing a
> > class
> > > > corresponding to the string name specifiied in the XML (associating
> > it
> > > > with
> > > > the specified MovieClip), and populates the newly created object
> > with
> > > the
> > > > parameter values specified in the XML.
> > > >
> > > > When we attempt to do this using RegisterClass, however, it appears
> > as
> > > > though the class name cannot be passed in as a string.
> > > >
> > > > This works:
> > > >
> > > > Object.RegisterClass("myClipSymbolName",
> > com.blackhammer.test.TestClass
> > > );
> > > >
> > > > This doesn't:
> > > >
> > > > Object.RegisterClass("myClipSymbolName", "
> > com.blackhammer.test.TestClass
> > > > ");
> > > >
> > > > Any clues?
> > > >
> > > > Perhaps there is a more elegant way of doing this anyway, since
> > > > RegisterClass seems to associate all instances of myTestClip (the
> > > symbol)
> > > > with the specified class. What we'd like to do is associate an
> > instance
> > > of
> > > > a
> > > > class with an instance of a movieclip.
> > > >
> > > > Thanks,
> > > >
> > > > August
> > > >
> > > > --
> > > > ---------------------------------------------------------
> > > > --------------------------------------------------------
> > > >
> > > > August Gresens
> > > > Technical Director
> > > > Black Hammer Productions, NYC
> > > > [EMAIL PROTECTED]
> > > >
> > > > ---------------------------------------------------------
> > > > --------------------------------------------------------
> > > > _______________________________________________
> > > > Flashcoders mailing list
> > > > Flashcoders@chattyfig.figleaf.com
> > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > >
> > >
> > >
> > >
> > > --
> > > j:pn
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> >
> >
> >
> > --
> > Jim Kremens
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
> ---------------------------------------------------------
> --------------------------------------------------------
>
> August Gresens
> Technical Director
> Black Hammer Productions, NYC
> [EMAIL PROTECTED]
>
> ---------------------------------------------------------
> --------------------------------------------------------
>



--
---------------------------------------------------------
--------------------------------------------------------

August Gresens
Technical Director
Black Hammer Productions, NYC
[EMAIL PROTECTED]

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

Reply via email to