Is there a performance and/or memory usage difference between the开发者_高级运维se two scenarios?
scenario 1: N visual elements all added to stage; N-1 have visible = false, 1 has visible = true;
scenario 2: N visual elements, only 1 added to the stage at any time.
thx!
Visible = false
is far faster.
Colin Moock has weighed in on this issue in a definitive manner. His findings:
10000 removeChild() calls took 300ms, whereas 10000 visible assignments took 7ms.
His basic guidelines are :
removeChild()
- for predictable control of the display list, add and remove.visible=false
- for straight up performance,visible
is clearly faster;
As far as "predictability" is concerned, we often use the display list as a stack to identify and control display objects. If you are leveraging visibility, you loose that state (which can be a big deal). Conclusively, though, if performance is required the winner is clear.
I realize your post is directed at Flex but I think, in this case, we're talking the behavior of an SWF and so flex/flash shouldn't matter.
精彩评论