Adding & removing display objects from contextview
I'm wondering what the cleanest & proper way of adding &
removing display objects from the context view is.
When my app starts, I add all my display objects at once to
contextview so that i can get the auto mediatior/view
happening.
At some point, I'll load an flv into one of these views & once
it's done playing, I remove all this displays objects children(flv,
controls, etc) as well as calling
contextView.removeChild(containerSprite).
Problem is, I'll be reloading the flv again at some point &
playing it. I tried just keeping the containersprite in the
contextview but i'm getting a memory leak. I know its not the
framework, but I'd like to remove the container completely from the
contextview & then add it again but still keep the injections.
Is this possible?? Is this a normal train of thought??
Any thoughts??
cheers
erick
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Jonny Reeves on 16 Mar, 2010 09:38 AM
Hi Erick,
What I usually end up doing in this case is to create a ContainerView which has public methods that allow you to add, and to remove DisplayObjects / Strongly Typed View instances to it.
I'll then couple this ContainerView with a ContainerMediator which will listen for framework events requesting that a child be added, or removed, from the ContainerView. The ContainerViewMediator is responsible for "cleaning up" the current view when a remove is requested.
Hope that helps?
Jonny.
3 Posted by erick on 16 Mar, 2010 11:51 PM
Hey Jonny!
Thx for the reply! Sounds like a great solution! I'll give it a go and implement it.
Cheers
erick
Stray closed this discussion on 11 Feb, 2011 11:32 PM.