From a19690f205c86afdc9203cc1ae67cbbb84dcc8a7 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 15 Oct 2008 20:45:27 +0000 Subject: [PATCH] Added countLayoutChildren(), which counts the children of a container that have includeInLayout = true. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@668 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flex/FlexUtil.as | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/as/com/threerings/flex/FlexUtil.as b/src/as/com/threerings/flex/FlexUtil.as index 62f0282d..7f1228bb 100644 --- a/src/as/com/threerings/flex/FlexUtil.as +++ b/src/as/com/threerings/flex/FlexUtil.as @@ -24,6 +24,7 @@ package com.threerings.flex { import mx.controls.Label; import mx.controls.Spacer; +import mx.core.Container; import mx.core.UIComponent; /** @@ -68,6 +69,21 @@ public class FlexUtil return spacer; } + /** + * Return a count of how many visible (includeInLayout=true) children + * are in the specified container. + */ + public static function countLayoutChildren (container :Container) :int + { + var layoutChildren :int = container.numChildren; + for each (var child :Object in container.getChildren()) { + if ((child is UIComponent) && !UIComponent(child).includeInLayout) { + layoutChildren--; + } + } + return layoutChildren; + } + /** * In flex the 'visible' property controls visibility separate from whether * the component takes up space in the layout, which is controlled by 'includeInLayout'.