?
Solved

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

Posted on 2007-10-20
2
Medium Priority
?
850 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:dban00b
2 Comments
 
LVL 23

Accepted Solution

by:
Zeffer earned 2000 total points
ID: 20116756
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
 
LVL 1

Author Comment

by:dban00b
ID: 20126963
Thanks for all the info, looks like my true solution lies in the middle ground somewhere depending on the complexity of the symbol.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question