views:

150

answers:

1

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?

A: 

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.

Branden Hall
I tried using a new ApplicationDomain() instead of ApplicationDomain.currentDomain, but that doesn't work for me because I'm dispatching events from the child swf. When I change the applicationDomain I get Type Coercion errors on the Events.
Ah, that wasn't explained in your original question. With ApplicationDomain it's basically all or nothing unless you want to cast across the domains (which is possible, though may be a pain). For that look into using ApplicationDomain.getDefinition. Your animals would just have to look up into the parent domain (you may have to pass that in) and then use it to create their instances of Event.
Branden Hall