Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you can. The problem is that <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html#getChildByName()" rel="nofollow noreferrer">DisplayObjectContainer.getChildByName()</a> returns type <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html" rel="nofollow noreferrer">DisplayObject</a>, and an arbitrary display object may or may not be a <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html" rel="nofollow noreferrer">DisplayObjectContainer</a>. So, while you can do that, you first need to cast the type of the result to a DisplayObjectContainer:</p> <pre><code>public static function getGrandChildByName( parent : DisplayObjectContainer, child : String, grandchild : String ) : DisplayObject { var child_obj : DisplayObject = parent.getChildByName(child); var child_container : DisplayObjectContainer = child_obj as DisplayObjectContainer; return child_container.getChildByName(grandchild); } </code></pre> <p>Note that in the example I gave above, I didn't do any checking to verify that the child is actually exists and is a DisplayObjectContainer.... in actual production code, you might want to add such checks.</p> <p>Also, one last note, if you are using type MovieClip, you can simply refer to the object by its name:</p> <pre><code> myclip.mc_child.mc_grandchild.gotoAndStop(3); </code></pre> <p>Simply refering to the elements by name is simpler and less error-prone. I highly recommend it.</p>
    singulars
    1. This table or related slice is empty.
    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