Question

can we get all the elements and all the descendants of those elements in a

VBox

? lets say i have Vobx, in which a grid is added.. and in grid there are many texinput controls.. i want to access all the descendants which are

Grid,GridRow,GridItem,TextInput

.. how to do that ?

Was it helpful?

Solution

You'll have to write a recursive function that traverses the hierarchy of components. There is no built-in method to access children below the first level of a container.

Something like:

function traceDisplayObject(object:DisplayObject):void {
  trace("Object: " + object);

  if (object is Container) {
    var container:Container = Container(object);
    var numChildren:uint = container.numChildren;

    for (var i:uint = 0; i<numChildren; i++) {
      traceDisplayObject(container.getChildAt(i));
    }
  }
}

traceDisplayObject(myVBox);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top