Packagestarlingbuilder.engine
Classpublic class LayoutLoader
InheritanceLayoutLoader Inheritance Object

Helper class to load layouts

This class provide an easy and efficient way to load layout files from embedded data, parse the data and cached it into memory. The following example load and parse the layout data from EmbeddedLayout class to ParsedLayout class:

     public class EmbeddedLayout
     {
         [Embed(source="layouts/connect_popup.json", mimeType="application/octet-stream")]
         public static const connect_popup:Class;
         
         [Embed(source="layouts/mail_popup.json", mimeType="application/octet-stream")]
         public static const mail_popup:Class;
     }
     
     public class ParsedLayout
     {
         public static var connect_popup:Object;
         
         public static var mail_popup:Object;
     }
     
     //loader with preload option
     var loader:LayoutLoader = new LayoutLoader(EmbeddedLayout, ParsedLayout);
     var sprite:Sprite = uiBuilder.create(ParsedLayout.connect_popup) as Sprite;
     
     //loader without preload option
     var loader2:LayoutLoader = new LayoutLoader(EmbeddedLayout, ParsedLayout, false);
     var sprite2:Sprite = uiBuilder.create(loader2.loadByClass(EmbeddedLayout.connect_popup));

See also

Starling Builder demo project


Public Methods
 MethodDefined By
  
LayoutLoader(embeddedCls:Class, layoutCls:Class, preload:Boolean = true)
Constructor
LayoutLoader
  
load(name:String):Object
Load a layout with name, only need to use it when preload = false
LayoutLoader
  
loadByClass(cls:Class):Object
Load a layout with the embedded data, only need to use it when preload = false
LayoutLoader
Constructor Detail
LayoutLoader()Constructor
public function LayoutLoader(embeddedCls:Class, layoutCls:Class, preload:Boolean = true)

Constructor

Parameters
embeddedCls:Class — class with embedded layout
 
layoutCls:Class — class with parsed layout
 
preload:Boolean (default = true) — whether to preload it. If set to true, calling load() or loadByClass() is not necessary
Method Detail
load()method
public function load(name:String):Object

Load a layout with name, only need to use it when preload = false

Parameters

name:String — layout name

Returns
Object — parsed as3 object
loadByClass()method 
public function loadByClass(cls:Class):Object

Load a layout with the embedded data, only need to use it when preload = false

Parameters

cls:Class — embedded data class

Returns
Object — parsed as3 object