Hi, I am looking for advice about swapping classes of the same name but using different methods.
Let's consider three classes: class SomeClass { public function meth() { trace("meth of skin SomeClass VERSION 0"); } } // class SomeClass { public function meth() { trace("meth of skin SomeClass VERSION 1"); } } // class SomeClass { public function meth() { trace("meth of skin SomeClass VERSION 2"); someNewMethod(); } private function someNewMethod() { trace("something new..."); } } The first of those is imported into a main.swf file. I can make an instance: var Q:SomeClass = new SomeClass(); Q.meth() // traces : meth of skin SomeClass VERSION 0 The next two classes are imported in: one storage1.swf and the other, storage2.swf Both .swf files are loaded into the main.swf. First the storage1.swf and next storage2.swf. But before loading, I delete the class: trace(SomeClass) // out: [type Function] delete SomeClass trace(SomeClass) // out: undefined And after loading the storage1.swf I can make again an instance of SomeClass: var Q1:SomeClass = new SomeClass(); Q1.meth() // traces: meth of skin SomeClass VERSION 1 It uses a new version of meth(). Now I delete the SomeClass class: delete SomeClass ... and load somewhere into the stage of main.swf the storage2.swf file. After loading the first one I can make a new instance of SomeClass: var Q2:SomeClass = new SomeClass(); Q2.meth() // traces: meth of skin SomeClass VERSION 2 // something new... and so on, deleting an loading a new version.... Now the question: The same class name, the same method name, eventually other, new methods of the same class and deleting the class.... Could this be a good way to overwrite classes ? I tested it and works. Flash allows deleting classes. But maybe I am not aware of some resulting problems. Is is ok in terms of good programing practices ? Thanks, Greg ---------------------------------------------------------------------- Lufa dla generala. Zobacz >> http://link.interia.pl/f19e1 _______________________________________________ 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