[Flashcoders] Clashing Class Names
Hi Flashcoders, Can somebody confirm my worst suspicions (think I am answering my own question here) swfA loads swfB Both swfs are compiled from separate classpaths but share a similar class structure, so swfA compiles classes like swfAProject/com/UserInterface/Application.as swfAProject/com/UserInterface/UIButton.as and swfB compiles swfBProject/com/UserInterface/Application.as swfBProject/com/UserInterface/UIButton.as I'm presuming that when swfB is loaded the _global.Application class is overwritten? As when I do this the whole thing spins off into 100% CPU hell. To separate these out will I need to restructure them to be...? CommonProject/com/A/UserInterface/Application.as CommonProject/com/B/UserInterface/Application.as (intergrating the code is not an option at this point). What would people suggest as best practice here? Apologies if this is a bit of a newb question on OO. Many thanks, Michael ___ 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] Clashing Class Names
You can not have the same classpath/class combinations. So if you were importing inside SWFA SWFB: com.this.is.my.class.path.Class But on the file system, SWFA points to: myproject1/com/this/is/my/class/path/Class.as And SWFB points to: myproject2/com/this/is/my/class/path/Class.as You will get errors because Flash would have used the first classpath/class loaded since it's stored and identified as a string. You would need to either alter the class path one one of those classes, or have the class path start from the project name and not 'com'. David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Trim Sent: Friday, June 22, 2007 9:14 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Clashing Class Names Hi Flashcoders, Can somebody confirm my worst suspicions (think I am answering my own question here) swfA loads swfB Both swfs are compiled from separate classpaths but share a similar class structure, so swfA compiles classes like swfAProject/com/UserInterface/Application.as swfAProject/com/UserInterface/UIButton.as and swfB compiles swfBProject/com/UserInterface/Application.as swfBProject/com/UserInterface/UIButton.as I'm presuming that when swfB is loaded the _global.Application class is overwritten? As when I do this the whole thing spins off into 100% CPU hell. To separate these out will I need to restructure them to be...? CommonProject/com/A/UserInterface/Application.as CommonProject/com/B/UserInterface/Application.as (intergrating the code is not an option at this point). What would people suggest as best practice here? Apologies if this is a bit of a newb question on OO. Many thanks, Michael ___ 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 ___ 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] Clashing Class Names
Michael, No, you have that backwards, but it's a similar problem -- the _global.Application class _isn't_ overwritten. The flash player operates a class cache -- it always stores (and uses) the first class of a particular classpath/name that it encounters. So in your case, when swfA loads, Flash caches a class called com.UserInterface.Application, and uses _that same class_ when swfB loads, ignoring swfB's implementation. Every attempt on your part beyond that point to refer to Application() will refer to swfA's version. You can get around this (as a hack) by calling delete _global.__Packages.com.UserInterface.Application; before loading swfB. Then swfB will use its own version of Application. But then swfA will have problems - it's not a brilliant solution in your case. What you really need is to separate the classpaths out in the way that you suggest. That'll certainly fix it. Cheers, Ian On 6/22/07, Michael Trim [EMAIL PROTECTED] wrote: Hi Flashcoders, Can somebody confirm my worst suspicions (think I am answering my own question here) swfA loads swfB Both swfs are compiled from separate classpaths but share a similar class structure, so swfA compiles classes like swfAProject/com/UserInterface/Application.as swfAProject/com/UserInterface/UIButton.as and swfB compiles swfBProject/com/UserInterface/Application.as swfBProject/com/UserInterface/UIButton.as I'm presuming that when swfB is loaded the _global.Application class is overwritten? As when I do this the whole thing spins off into 100% CPU hell. To separate these out will I need to restructure them to be...? CommonProject/com/A/UserInterface/Application.as CommonProject/com/B/UserInterface/Application.as (intergrating the code is not an option at this point). What would people suggest as best practice here? Apologies if this is a bit of a newb question on OO. Many thanks, Michael ___ 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 ___ 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] Clashing Class Names
Hi Ian, Yes a quick replace all in the classes for swfb (with careful checking of the results) has solved the problem for now. (Although having to update all the class paths in the library manually was a pain, I hope this is easier in CS3). Thanks for your reply it's interesting to know that that is the actual behavior. Michael -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: 22 June 2007 15:04 To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Clashing Class Names Michael, No, you have that backwards, but it's a similar problem -- the _global.Application class _isn't_ overwritten. The flash player operates a class cache -- it always stores (and uses) the first class of a particular classpath/name that it encounters. So in your case, when swfA loads, Flash caches a class called com.UserInterface.Application, and uses _that same class_ when swfB loads, ignoring swfB's implementation. Every attempt on your part beyond that point to refer to Application() will refer to swfA's version. You can get around this (as a hack) by calling delete _global.__Packages.com.UserInterface.Application; before loading swfB. Then swfB will use its own version of Application. But then swfA will have problems - it's not a brilliant solution in your case. What you really need is to separate the classpaths out in the way that you suggest. That'll certainly fix it. Cheers, Ian On 6/22/07, Michael Trim [EMAIL PROTECTED] wrote: Hi Flashcoders, Can somebody confirm my worst suspicions (think I am answering my own question here) swfA loads swfB Both swfs are compiled from separate classpaths but share a similar class structure, so swfA compiles classes like swfAProject/com/UserInterface/Application.as swfAProject/com/UserInterface/UIButton.as and swfB compiles swfBProject/com/UserInterface/Application.as swfBProject/com/UserInterface/UIButton.as I'm presuming that when swfB is loaded the _global.Application class is overwritten? As when I do this the whole thing spins off into 100% CPU hell. To separate these out will I need to restructure them to be...? CommonProject/com/A/UserInterface/Application.as CommonProject/com/B/UserInterface/Application.as (intergrating the code is not an option at this point). What would people suggest as best practice here? Apologies if this is a bit of a newb question on OO. Many thanks, Michael ___ 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 ___ 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 ___ 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] Clashing Class Names
It's not different in CS3 or easier to fix if you mess up. When using as classpath like com.UserInterface you might as well not use one at all. There's nothing unique about it, which it should be. com.projectA.userInterface.MyClass com.projectB.userInterface.MyClass that's what you should aim for. regards, Muzak - Original Message - From: Michael Trim [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Friday, June 22, 2007 4:43 PM Subject: RE: [Flashcoders] Clashing Class Names Hi Ian, Yes a quick replace all in the classes for swfb (with careful checking of the results) has solved the problem for now. (Although having to update all the class paths in the library manually was a pain, I hope this is easier in CS3). Thanks for your reply it's interesting to know that that is the actual behavior. Michael ___ 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