1

I have a simple expandable advertisement which loads an external SWF file. The external SWF file contains an embedded video.

Using the UILoader component, I have loaded the SWF, added it to the stage and the video displays and plays fine.

The main issue is that I have a close button, which should unload the video, and stop it, essentially returning to the default state of the advertisement.

To unload the SWF, I am doing the following:

myUILoader.unload();
removeChild(myUILoader);

When I do this, the video and UILoader disappear from the screen. However, you can still hear the sound in the background, and if I load the SWF again, it creates multiple tracks in the background. Any suggestions?

Chris
  • 4,762
  • 3
  • 44
  • 79
  • what happens if you set `myUILoader` to null? What you should really do is in the SWF you're loading, edit the code and add a `Event.REMOVED_FROM_STAGE` event that handles stopping all necessary sounds/videos. – Ronnie Aug 06 '12 at 21:48

1 Answers1

1

There are a couple of things that could cause this. One is that the content inside your UILoader is adding event listeners to outside of itself. You can fix this by not allowing it to touch anything outside itself. I believe you can do this by placing it either in its own ApplicationDomain, SecurityDomain, or both. Consult the help for more details.

If this is not feasible, you can try SoundMixer.stopAll(), which will stop the obvious symptom, but will not fix the memory leak you probably have in this situation.

Another possibility, as Ronnie has alluded to, is that you still have a reference to the content of the loader somewhere. If you don't clear that, it will stay in memory.

However, there is another problem that can also cause this, which is that if there is navigation in the movie that skips over a frame that contains a MovieClip with audio set to "stream," the MC will be created but not fully instantiated and will stay in memory with no way to get any control over it or release it. I don't think this is what is happening from your description. If it is, the fix is to make sure that you visit the frame that contains the sound, however briefly, on the way to the other frame. This is actually something you might want to consider even without sounds, because it does occur any time you skip frames in nested MovieClips (you just have no evidence unless you profile the swf), and over time this will create a memory leak.

Amy Blankenship
  • 6,485
  • 2
  • 22
  • 45