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:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
package com.threerings.flex {
|
package com.threerings.flex {
|
||||||
|
|
||||||
|
import flash.display.DisplayObject;
|
||||||
|
|
||||||
import mx.controls.Label;
|
import mx.controls.Label;
|
||||||
import mx.controls.Spacer;
|
import mx.controls.Spacer;
|
||||||
import mx.controls.Text;
|
import mx.controls.Text;
|
||||||
@@ -28,6 +30,9 @@ import mx.controls.Text;
|
|||||||
import mx.core.Container;
|
import mx.core.Container;
|
||||||
import mx.core.UIComponent;
|
import mx.core.UIComponent;
|
||||||
|
|
||||||
|
import mx.containers.HBox;
|
||||||
|
import mx.containers.VBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flex-related utility methods.
|
* Flex-related utility methods.
|
||||||
*/
|
*/
|
||||||
@@ -111,5 +116,51 @@ public class FlexUtil
|
|||||||
component.includeInLayout = visible;
|
component.includeInLayout = visible;
|
||||||
return 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user