Sprites:: Visible=true/false VS addChild()/removeChild()

In a flash game, there are different sprites that:
a)may not even be in the current level
b)may be in the current level, but not visible
c)may be in the current level and visible

Currently, I resolve (a) and (b) the same way, removeChild();
and when the state changes to (c), addChild();

I was wondering if this is the most efficient way, or if it would be more efficient to simply make the inactive sprites visible=false, and then visible=true rather than constantly adding and removing changes.

add/remove child() Questions:
PRO, releases memory when they are not even there??
CON, high impact on performance when adding/removing than changing visible??

visible Questions:
PRO, low impact on performance when changing the visible parameter??
CON, non-visible sprites still exist in memory eating up resources??

Thanks.
LVL 1
dban00bAsked:
Who is Participating?
 
ZefferCommented:
add/remove child() Questions:
PRO, releases memory when they are not even there??
//Yes definately
CON, high impact on performance when adding/removing than changing visible??
// No. Changing visible leaves resources running at the same level
// Adding will use more resource as it has to be loaded again..but if you have removed (some) then you have created headroom for the player..removing them (clean-up) will be a small task compared to loading

visible Questions:
PRO, low impact on performance when changing the visible parameter??
//Yes.. but as above the resourse is still running..the advantage (if you have the processor room) is that it does not have to be re-loaded and is immediately drawn.
CON, non-visible sprites still exist in memory eating up resources??
//Yes

so the whole issue is a trade-off between available resources and a seamless experience..depending on the demand on the player.
you could identify sprites which don't demand a lot of the player and visible=false those ..and remove the more demanding ones if (as) they are not needed and re-load if they are..which shouldn't be a problem to a player that's cruising.

Z
0
 
dban00bAuthor Commented:
Thanks for all the info, looks like my true solution lies in the middle ground somewhere depending on the complexity of the symbol.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.