R – flash as3 – Can’t have classes of the same name in different swfs

actionscript-3classflashnamespaces

Say I have 3 different swfs: dog.swf, cat.swf, mouse.swf, and each has their corresponding fla file. In the fla files I have movie clips like "head" and "tail", which are exported for Actionscript with names like Head and Tail, and each just contains an image.

The problem comes when I have a main swf that loads and unloads these animal swfs. If I load dog.swf, remove it from the display list, then display cat.swf, I will get images of the dog in the cat swf (even though the cat is fine if compiled separately). I think it's because in the document class for both Cat and Dog I have something like this:

private var head:Head;
private var tail:Tail;

And flash has a conflict with both Cats and Dogs having Head and Tail classes. Yes, I can go into the Cat .fla and rename the Head movie clip as "CatHead", etc., but at this point doing that for all parts of all animals would be a lot of work. How can I get flash to allow different classes to have class properties with the same name?

Best Answer

I'll try to provide more details later, but the core thing is that you'll need to use ApplicationDomain to specify that you want the SWFs kept in thier own little sandbox. You set the application domain through your instance of Loader.

Related Topic