Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If a parent's <em>visible</em> property is set to <code>false</code>, none of its children will be visible in the stage. But that doesn't mean that children's <em>visible</em> properties would be automatically set to false - they will continue to hold their original values.</p> <p>In short, a <code>DisplayObject</code> with <em>visible</em> property <code>true</code> need not be visible on the stage - it depends on its parents' <em>visible</em> value too. But if an object's <em>visible</em> is set to <code>false</code>, it will not be visible no matter what.</p> <p>Compile the following code and click on the text field to understand it better. The textfield will become invisible (as it's parent's <em>visible</em> is set to <code>false</code>), but its own <em>visible</em> property continues to be <code>true</code></p> <pre><code>private var sprite:Sprite; private var tf:TextField; public function init():void { sprite = new Sprite(); addChild(sprite); tf = new TextField(); tf.text = "sometext"; sprite.addChild(tf); sprite.addEventListener(MouseEvent.CLICK, onClick) } private function onClick(e:MouseEvent):void { sprite.visible = false; trace(tf.visible);//traces true - but tf is not displayed. } </code></pre> <hr> <p>Update to answer clorz' question on how to check if an object is visible or not:</p> <pre><code>function isVisible(t:DisplayObject):Boolean { if(t.stage == null) return false; var p:DisplayObjectContainer = t.parent; while(!(p is Stage)) { if(!p.visible) return false; p = p.parent; } return true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload