Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly, you're asking for a way to get all the "elements" in a Flex application that have a certain name.</p> <p>Here's an example (Flex 3):</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function testIt():void { var arr:Array = getDisplayObjectsByName(this, "foo"); for each (var e:* in arr) trace(e); } private static function getDisplayObjectsByName(node:DisplayObjectContainer, name:String, recurse:Boolean = true):Array { var n:int = node.numChildren; var a:Array = []; for (var i:int = 0; i &lt; n; i++) { var c:DisplayObject = node.getChildAt(i); if (c.name == name) a.push(c); if (recurse) { if (c is DisplayObjectContainer) a = a.concat(getDisplayObjectsByName(DisplayObjectContainer(c), name, true)); } } return a; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:VBox name="foo"&gt; &lt;mx:HBox&gt; &lt;mx:Button name="foo" label="Test" click="testIt()" /&gt; &lt;/mx:HBox&gt; &lt;/mx:VBox&gt; &lt;mx:Label text="Ignore Me" /&gt; &lt;mx:VBox name="bar"&gt; &lt;/mx:VBox&gt; &lt;/mx:Application&gt; </code></pre> <p>Here we're looking for all the elements called "foo" when the user clicks the "Test" button.</p> <p>Output:</p> <pre><code>main0.foo main0.foo.HBox5.foo </code></pre> <p>You'll notice that <code>getDisplayObjectsByName()</code> is <code>static</code>. All it does is traverse the display list (depth-first) and pick out all the objects with the specified name.</p>
    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. This table or related slice is empty.
    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