How do you make Flash not render an object on the Stage?

橙三吉。 提交于 2019-12-25 00:14:45

问题


This discussion started over here but I thought it would be nice to have a definitive answer...

So let's say you have MovieClip on the Stage (or a UIComponent for the Flex audience) - what do you have to do to not make it so that the user can't see the object but also so that the AVM2 doesn't even factor it in when rendering the stage for the user?

I always thought the answer was to set visible = false but there is an argument out there that the object has to placed outside the boundaries of the Stage (like x = 2000 which seems like a hack IMO). Does anyone know the real answer?

EDIT: I imagine the need for having flash not render the item would be to help performance.


回答1:


The hack is for Flash 8 (Actionscript 2) or below. With the upgrades to Actionscript 3 and Flex 2/3 setting the visible property is enough.




回答2:


As other answers have noted, the "hack" for moving clips outside the stage is no longer necessary. However, setting visible = false; is not a smart thing to do if performance is important. Clips that are part of the display list, but set to be invisible, can still incur a significant rendering overhead if you have enough of them. If you remove them from the playlist with removeChild(), they incur no rendering overhead (although they still take up memory).




回答3:


Yeah, as design said, just remove it from the display list:

var s:MovieClip = new MovieClip();
s.lineStyle(1, 0xFFFFFF);
addChild(s);//shows in moviea 
removeChild(s);//removes from display list, but you still have a reference to it

I havent tested that, but it should give you the general idea.

mike




回答4:


If you're using Flex and its container layout system, the includeInLayout property in the UIComponent class is also useful when you don't want to display something: it specifies whether or not to factor the component in when measuring the layout.




回答5:


Remove it from the display list completely (removeChild(), removeChildAt(), etc.). As long as you don't actually set the reference to the MovieClip to "null", it will still remain in memory and can be re-added to the display list when you need it again (addChild(), atChildAt(), etc.)



来源:https://stackoverflow.com/questions/170203/how-do-you-make-flash-not-render-an-object-on-the-stage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!