I am working in on a Flex / Air application (using PureMVC) written virtually entirely in ActionScript 3 (i.e. we use very little of Flex). View components are added to a Canvas object in the main application window and these Views then load other movie clips, images files, etc.
When I remove a View from the stage, I do so using application.canvas.removeChild(...)
. This fires an event in my PureMVC mediator for that View, which removes any event listeners that were set up and everything appears to be dandy.
However, the movie clips are still playing in the background. They are not causing any trouble on screen ... but they are simply there, playing somewhere in memory (e.g. I can see trace
statements from them) and I want them gone. I suspect the View that was removed from the Canvas is still there too, but I can't prove it.
Setting the View to null
doesn't do anything. I'm surprised that AS3 doesn't include any method to simply and effectively destroy a Display Object and all of its children.
Is the only way to do this to tediously unload all of the movie clips, etc. and then hope that Flash will clean them up?