Hi,
it works, it probably results in problems in the long run, and i don't think
it's good programming practice.
I had the same issue a while ago and the same solution, but in the end it's
probably better to compile using intrinsic classes or abstract interfaces
and loading a class library at runtime or something like that,

greetz
JC


On 1/16/07, BlackMail <[EMAIL PROTECTED]> wrote:

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


_______________________________________________
[email protected]
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

_______________________________________________
[email protected]
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

Reply via email to