[Flashcoders] How does registerClass() / registerClassAlias() work internally?
It always intrigued me how this method worked internally. First, when I register this (AS2): Object.registerClass('mylinkageid_or_myobjectname',myclass); 1)How does flash knows that each time I create a new instance of the object/movieclip symbol it should attach it to the class specified? Is it internal to the Flash Player OR is it implemented in pure ActionScript? Does Flash keep a kind of a dictionary list or hash table to keep all these values? 2)What also defies me is how does flash automatically instantiates the correct Value Object class when you use a application server such as AMFPHP 1.2... does AMFPPHP send a class namepsace metadata together with the object and the flash remoting engine reads that and then applies the correct class depending on the class that has been registered with registerClass() / registerClassAlias() (Flex 2)? Thanks, Marcelo. ___ 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
Re: [Flashcoders] How does registerClass() / registerClassAlias() work internally?
Marcelo de Moraes Serpa wrote: It always intrigued me how this method worked internally. First, when I register this (AS2): Object.registerClass('mylinkageid_or_myobjectname',myclass); 1)How does flash knows that each time I create a new instance of the object/movieclip symbol it should attach it to the class specified? Is it internal to the Flash Player OR is it implemented in pure ActionScript? Does Flash keep a kind of a dictionary list or hash table to keep all these values? I believe it is internal to the flash player. The same mechanism is used for local shared objects. I dont know how its stored or how it works and i've not noticed anything relating to it in the remoting source code that they provide. 2)What also defies me is how does flash automatically instantiates the correct Value Object class when you use a application server such as AMFPHP 1.2... does AMFPPHP send a class namepsace metadata together with the object and the flash remoting engine reads that and then applies the correct class depending on the class that has been registered with registerClass() / registerClassAlias() (Flex 2)? exactly. if you look at the AMFPHP source (or some AMF specs...i just have the source to hand) you'll see that the classname is written into the AMF packet by the serializer : $this-writeUTF($classname); // write the class name (in AMFSerializer.php) the player then reads the AMF packet, decodes the class name and instantiates that type for you. thanks. Martin ___ 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