1

Using: Adobe Flash CS6 Exporting: Flash player 11.2 OS: OSX/Windows

Heya guys. I've been having this huge issue for a while now. I'm working on an educational game. This main SWF loads several other SWFs. Since it's a bilingual game, each activity has two versions, the spanish and the english one.

Now to the main concern. Let's say I have this activity called 'hangman'. I have the 'hangman.swf' which is the spanish version and the 'hangmanE.swf' which is the english one. They're virtually the same except for the actual assets used. Both are loaded by a master SWF. So in their libraries I have a sound which has a class called 'AudioInstruction', which is the activity's instruction. The actual file is different since I need one for each language, but the class given is the same.

File map:

  • Master.swf
    • Hangman.swf
    • HangmanE.swf

The problem comes when I open the spanish version and then I switch to the english one or vise versa. Since the english one was opened second, it actually ignores it's internal 'AudioInstruction' file and just plays the spanish one. As if having an asset with the same class name makes the second SWF ignore its own assets. Has anyone encountered this problem?

It can happen with any type of asset MovieClip, Sound or Graphic. I thought it was because of in frame coding, but I made them class based and they still have this issue. This isn't exclusive to any OS, it happens in both Windows and Mac OSX.

2 Answers2

1

Place the loaded SWF into another application domain (see the ApplicationDomain class).

Partition the child SWF file by creating a child of the system domain. In the diagram, Application domain 2 is created as a child of the system domain. [...] One use of this technique is to have an old application dynamically loading a newer version of the same application without conflict. There is no conflict because although the same class names are used, they are partitioned into different application domains.

Reference: Working with Application Domains

Antoine Lassauzay
  • 1,557
  • 11
  • 12
  • Thanks man, I worked once with Application Domains, like... years back. I'll check it out. – Rogelio Alejandro Espinoza Aug 06 '13 at 19:23
  • Just wanted to say that this worked like a charm. When I load each 'master' SWF I create a new instance of the AppDomain, LoaderContext and Loader. And after unloading it I set the three of them to null. It needs more testing, but I think this solved my issue. Thanks again. – Rogelio Alejandro Espinoza Aug 06 '13 at 20:16
0

Try calling yourLoaderName.unloadAndStop() on the Loader that loaded the first swf, before loading the second swf.

See docs for more info

It's sounds like Flash is still hanging on to the first swfs assets and when the second swf gets loaded it sees that it already has many of the same assets in memory.

ToddBFisher
  • 11,370
  • 8
  • 38
  • 54
  • Thanks for your answer. That's what blows my mind, I am using unloadAndStop on the SWF that loads the 'master' (which would be the 'world' SWF). But in the actual master I'm using UILoader. Sadly there's like 10 'master' SWFs and converting all to Loader is not approved by the project manager due to budget reasons. And I am using unload() on the UILoaders. – Rogelio Alejandro Espinoza Aug 06 '13 at 19:23