开发者

get all the descendants Elements(controls) of VBox(container) in flex?

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 ar开发者_JS百科e many texinput controls.. i want to access all the descendants which are

Grid,GridRow,GridItem,TextInput

.. how to do that ?


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜