Thanks for the reply.
Also, it seems like a very bad idea to have 2 classes share a name. I thought one goal of using swfs to contain classes was to make upgrades easy?
I understand your quandry with legacy code, but I don't believe trying to overwrite an existing class makes sense. Can't you use 'extends' to add your new method?
 
- - - - - - - - - - - -
Tim Beynart
Athens, GA, USA
- - - - - - - - - - - -
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicolas Désy
Sent: Thursday, October 13, 2005 1:21 PM
To: Open Source Flash Mailing List
Subject: Re: [osflash] Using swf to import external classes

Hi Jim,
 
The classes are stored in _global.  So in theory you can manually override the class (not tested yet)
 
 
class com.mycompany.MyClassV2 {
 ...
}
 
// code on the _root of movieB.swf
_global.com.mycompany.MyClass = com.mycompany.MyClassV2;
 
 
Nicolas
----- Original Message -----
Sent: Thursday, October 13, 2005 1:02 PM
Subject: Re: [osflash] Using swf to import external classes

Thanks for your recommendations.  The problem is that this is a complex environment with multiple teams of developers from multiple companies attempting (in theory at this point) to use the same codebase.  Might not even be possible...
 
Regarding your comment "There's no simple way to have two classes with exactly the same name"
 
Is there any way at all?  I can only think of hideous hacks...
 
Jim Kremens

 
On 10/13/05, David Rorex <[EMAIL PROTECTED]> wrote:
On 10/13/05, Jim Kremens <[EMAIL PROTECTED]> wrote:
> Regarding loading of classes via swf, you can run into a problem if you're
> in a large, complex environment.  Consider the following...
>
> - Assume a SWF, named 'loader.swf'
> - loader.swf loads movieA.swf, which was compiled in 2003.
> - movieA.swf uses a class called 'MyClass'.
> - movieA's version of 'MyClass' is written into the Flash player's _global
> namespace.
> - loader.swf loads movieB.swf, compiled in 2005.
> - movieB.swf also uses 'MyClass', but a different version with an additional
> method.
> - That additional method will not work, as the _global namespace for
> 'MyClass' has already been filled by the old, 'stale' 2003 version of
> 'MyClass'. The newer version is disregarded.
>
> How can you handle the case where different versions of the same class are
> required when the VM keeps only the first version to get written to the
> global namespace?

Name your classes differently, or use a different package name.
There's no simple way to have two classes with exactly the same name.
You could name your classes like:
com.company.v1.MyClass
com.company.v2.MyClass

Or, if you really don't want to recompile, have your loader load
movieB.swf first. Or if that's not an option, create a swf that only
contains the new MyClass, than have it load:
1. newMyClass.swf
2. movieA.swf
3. movieB.swf

-David R

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org


_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to