Some more useful methods for FlexUtil for creating layout containers and wrappers inline.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@859 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Jamie Doornbos
2009-10-26 20:52:04 +00:00
parent 292ca25d5a
commit ad67558798
+51
View File
@@ -21,6 +21,8 @@
package com.threerings.flex {
import flash.display.DisplayObject;
import mx.controls.Label;
import mx.controls.Spacer;
import mx.controls.Text;
@@ -28,6 +30,9 @@ import mx.controls.Text;
import mx.core.Container;
import mx.core.UIComponent;
import mx.containers.HBox;
import mx.containers.VBox;
/**
* Flex-related utility methods.
*/
@@ -111,5 +116,51 @@ public class FlexUtil
component.includeInLayout = visible;
return visible;
}
/**
* Creates a new container of the given class and adds the given children to it.
*/
public static function createContainer (clazz :Class, ...children) :Container
{
var container :Container = new clazz() as Container;
for each (var comp :UIComponent in children) {
container.addChild(comp);
}
return container;
}
/**
* Creates a new HBox container and adds the given children to it.
*/
public static function createHBox (...children) :Container
{
children.unshift(HBox);
return createContainer.apply(null, children);
}
/**
* Creates a new VBox container and adds the given children to it.
*/
public static function createVBox (...children) :Container
{
children.unshift(VBox);
return createContainer.apply(null, children);
}
/**
* Creates a simple UIComponent that wraps a display object.
*/
public static function wrap (obj :DisplayObject) :FlexWrapper
{
return new FlexWrapper(obj);
}
/**
* Creates a simple UIComponent that wraps a display object and inherits its size.
*/
public static function wrapSized (obj :DisplayObject) :FlexWrapper
{
return new FlexWrapper(obj, true);
}
}
}