开发者

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

开发者 https://www.devze.com 2023-01-31 04:56 出处:网络
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 wan

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

精彩评论

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

关注公众号