views:

653

answers:

5

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.

+2  A: 

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.

I agree. I should have specified this in my answer to the other question.
Max Stewart
Wow - well that was easy enough...
onekidney
This answer is not correct, unless performance is irrelevant. Invisible clips still incur rendering overhead; it just doesn't matter where they're located. See my answer below for details.
fenomas
+1  A: 

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.

hasseg
Wow - that is handy to know.
onekidney
+1  A: 

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.)

restlessdesign
+2  A: 

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

mikechambers
+3  A: 

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).

fenomas