| Package | starlingbuilder.engine | 
| Class | public class UIBuilder | 
| Inheritance | UIBuilder  Object | 
| Implements | IUIBuilder | 
Exmaple of creating a UIBuilder
         var assetManager:AssetManager = new AssetManager();
         var assetMediator:AssetMediator = new AssetMediator(assetManager);
         var uiBuilder:UIBuilder = new UIBuilder(assetMediator);A simple example to create display objects from layout
         var sprite:Sprite = uiBuilder.create(layoutData) as Sprite;
         addChild(sprite);A more elaborate way to create UI element inside a class, and bind the public underscore property automatically
         public class MailPopup extends Sprite
         {
             //auto bind variables
             public var _list:List;
             public var _exitButton:Button;
             
             public function MailPopup()
             {
                 super();
                 
                 var sprite:Sprite = uiBuilder.create(ParsedLayouts.mail_popup, true, this) as Sprite;
                 addChild(sprite);
                 
                 _exitButton.addEventListener(Event.TRIGGERED, onExit);
             }
             
             private function onExit(event:Event):void
             {
                 PopUpManager.removePopUp(this, true);
             }
         }See also
| Property | Defined By | ||
|---|---|---|---|
| localization : ILocalization 
         
         Localization property
          | UIBuilder | ||
| localizationHandler : ILocalizationHandler 
         
         Localization handler property
          | UIBuilder | ||
| tweenBuilder : ITweenBuilder 
         
         Tween builder property
          | UIBuilder | ||
| Method | Defined By | ||
|---|---|---|---|
| UIBuilder(assetMediator:IAssetMediator, forEditor:Boolean = false, template:Object = null, localization:ILocalization = null, tweenBuilder:ITweenBuilder = null) 
         Constructor
          | UIBuilder | ||
| bind(view:Object, paramsDict:Dictionary):void [static] 
          Helper function to bind UI elements to properties. | UIBuilder | ||
| create(data:Object, trimLeadingSpace:Boolean = true, binder:Object = null):Object 
         Create display objects from layout. | UIBuilder | ||
| createUIElement(data:Object):Object 
         
         Create UI element from data
                   | UIBuilder | ||
| find(container:DisplayObjectContainer, path:String):DisplayObject [static] 
          Helper function to find ui element
          | UIBuilder | ||
| load(data:Object, trimLeadingSpace:Boolean = true, binder:Object = null):Object 
         Load from layout data, create display objects and the associated meta data
                   | UIBuilder | ||
| localizeTexts(root:DisplayObject, paramsDict:Dictionary):void 
         
         Localize texts in display object
                   | UIBuilder | ||
| save(container:DisplayObjectContainer, paramsDict:Object, version:String, setting:Object = null):Object 
         
         Save display object container to layout data
                   | UIBuilder | ||
| localization | property | 
localization:ILocalizationLocalization property
    public function get localization():ILocalization    public function set localization(value:ILocalization):void| localizationHandler | property | 
localizationHandler:ILocalizationHandlerLocalization handler property
    public function get localizationHandler():ILocalizationHandler    public function set localizationHandler(value:ILocalizationHandler):void| tweenBuilder | property | 
tweenBuilder:ITweenBuilderTween builder property
    public function get tweenBuilder():ITweenBuilder    public function set tweenBuilder(value:ITweenBuilder):void| UIBuilder | () | Constructor | 
public function UIBuilder(assetMediator:IAssetMediator, forEditor:Boolean = false, template:Object = null, localization:ILocalization = null, tweenBuilder:ITweenBuilder = null)Constructor
Parameters| assetMediator:IAssetMediator— asset mediator | |
| forEditor:Boolean(default =false)— whether it's used for the editor | |
| template:Object(default =null)— template for saving layout | |
| localization:ILocalization(default =null)— optional localization instance | |
| tweenBuilder:ITweenBuilder(default =null)— optional tween builder instance | 
| bind | () | method | 
 public static function bind(view:Object, paramsDict:Dictionary):voidHelper function to bind UI elements to properties. It loops through all the UI elements, if the name starts with "_", then bind to the object property with the same name.
NOTE: This function will ONLY work if your object._xxx is public variable.
Parameters
| view:Object— object you want to bind to | |
| paramsDict:Dictionary— params dictionary of meta data | 
| create | () | method | 
 public function create(data:Object, trimLeadingSpace:Boolean = true, binder:Object = null):ObjectCreate display objects from layout. Short cut for load().object
Parameters
| data:Object | |
| trimLeadingSpace:Boolean(default =true) | |
| binder:Object(default =null) | 
| Object | 
See also
| createUIElement | () | method | 
 public function createUIElement(data:Object):ObjectCreate UI element from data
Parameters
| data:Object—         data in as3 plain object format | 
| Object— starling display object | 
| find | () | method | 
 public static function find(container:DisplayObjectContainer, path:String):DisplayObjectHelper function to find ui element
Parameters
| container:DisplayObjectContainer— root display object container you want to find | |
| path:String— path separated by dots (e.g. bottom_container.layout.button1) | 
| DisplayObject— | 
| load | () | method | 
 public function load(data:Object, trimLeadingSpace:Boolean = true, binder:Object = null):ObjectLoad from layout data, create display objects and the associated meta data
Parameters
| data:Object—         layout data | |
| trimLeadingSpace:Boolean(default =true)—         whether to trim the leading space on the top level elements
         set to true if loading a popup, set to false if loading a hud | |
| binder:Object(default =null)—         An optional object you want to bind properties with UI components with the same name, if name starts with "_" | 
| Object— An object with {object:Sprite, params:Dictionary, data:data};object: the sprite to create params: A Dictionary of the mapping of every UIElement to its layout data data: the as3 plain object format of the layout | 
See also
| localizeTexts | () | method | 
 public function localizeTexts(root:DisplayObject, paramsDict:Dictionary):voidLocalize texts in display object
Parameters
| root:DisplayObject— of the DisplayObject needs to be localize | |
| paramsDict:Dictionary— Dictionary of the mapping of every UIElement to its layout data | 
| save | () | method | 
 public function save(container:DisplayObjectContainer, paramsDict:Object, version:String, setting:Object = null):ObjectSave display object container to layout data
Parameters
| container:DisplayObjectContainer—         Display object container needed to export to layout | |
| paramsDict:Object—         A Dictionary of the mapping of every UIElement to its layout data | |
| version:String—         project setting like canvas size, background info used by the editor | |
| setting:Object(default =null) | 
| Object— layout file data |