Packagede.mightypirates.asul.interfaces
Interfacepublic interface IAsulFactory extends flash.events.IEventDispatcher, IDisposable
ImplementorsAsulFactory

Interface for the AsulFactory class.



Public Properties
 PropertyDefined by
  isLoading : Boolean
[read-only] Tells whether there is currently a loading process going on, i.e.
IAsulFactory
  linkResolver : Function
A function used to resolve links of elements with a set "url" attribute.
IAsulFactory
  localizer : ILocalizer
[read-only] Resolve strings that should be localized with this localizer.
IAsulFactory
  scriptContext : Object
[read-only] The context object used for scripts in ASUL files loaded through this factory, and objects generated through this factory.
IAsulFactory
  styleSheet : IStyleSheet
[read-only] The stylesheet used by this factory.
IAsulFactory
  variables : Dictionary
[read-only] Variables used when solving number expressions for anchors and the like.
IAsulFactory
Public Methods
 MethodDefined by
  
Creates an exact copy of the original factory.
IAsulFactory
  
Copies all variables registered with another factory instance to this instance.
IAsulFactory
  
createAsulObjectById(id:String, asulType:Class = null, silent:Boolean = false):DisplayObject
Function provided to make it easier to access graphics objects defined in this ASUL definition files.
IAsulFactory
  
createAsulObjectFromXml(xml:XML, applyStylesheet:Boolean = true):DisplayObject
This factory function can be used to create a new ASUL object from some XML data.
IAsulFactory
  
createTooltip(owner:DisplayObject, text:String = ""):ITooltip
Creates a new tooltip using the common TooltipFactory.
IAsulFactory
 Inherited
dispose():void
Cleans upd the object, removing all listeners, timers and references that might keep the object from being garbage collected.
IDisposable
  
disposeDisplayObject(object:Object, disposeBitmapData:Boolean = false, disposeObject:Boolean = true):void
This function just calls the function of the same name in the de.mightypirates.utils package.
IAsulFactory
  
getAbsPath(path:String):String
A function used to resolve paths from relative to absolute.
IAsulFactory
  
getAsulDefinitionById(id:String):XML
Returns the original ASUL definition of the element with the given id.
IAsulFactory
  
hasElementWithId(id:String):Boolean
Checks if an object with the given id can be instantiated, i.e.
IAsulFactory
  
load(path:String):void
Loads additional definitions from the file at the given location.
IAsulFactory
  
loadXML(data:XML):void
Loads additional definitions from the given XML data.
IAsulFactory
  
registerScriptVariable(name:String, value:*):void
Registers a variable for the script context of scripts in ASUL files loaded into this factory.
IAsulFactory
  
registerVariable(name:String, value:Number):void
Registers a variable with its value that can be used in number expressions (when evaluating anchors).
IAsulFactory
Property detail
isLoadingproperty
isLoading:Boolean  [read-only]

Tells whether there is currently a loading process going on, i.e. if it is possible to start a new one (false) or not (true).

Implementation
    public function get isLoading():Boolean
linkResolverproperty 
linkResolver:Function  [read-write]

A function used to resolve links of elements with a set "url" attribute. The function signature must be as follows:
function(factory:IAsulFactory, url:String, target:String = null):void

WARNING: this in fact sets a static variable, therefore this represents the resolver used for all factories!

The default implementation uses the navigateToURL function and ignores the factory reference.

The idea of the factory reference is to allow differentiation between factories even though this is a static variable / function. This may seem a bit roundabout (which it is), but for the most cases this will be the easier way (where only one resolver is used for the whole application). Implementation
    public function get linkResolver():Function
    public function set linkResolver(value:Function):void

localizerproperty 
localizer:ILocalizer  [read-only]

Resolve strings that should be localized with this localizer.

Implementation
    public function get localizer():ILocalizer
scriptContextproperty 
scriptContext:Object  [read-only]

The context object used for scripts in ASUL files loaded through this factory, and objects generated through this factory.

Implementation
    public function get scriptContext():Object
styleSheetproperty 
styleSheet:IStyleSheet  [read-only]

The stylesheet used by this factory.

Implementation
    public function get styleSheet():IStyleSheet
variablesproperty 
variables:Dictionary  [read-only]

Variables used when solving number expressions for anchors and the like.

Implementation
    public function get variables():Dictionary
Method detail
clone()method
public function clone():IAsulFactory

Creates an exact copy of the original factory.

Returns
IAsulFactory — a copy of the factory.
copyVariables()method 
public function copyVariables(factory:IAsulFactory):void

Copies all variables registered with another factory instance to this instance.

Parameters
factory:IAsulFactory — the factory from which to copy the variables.
createAsulObjectById()method 
public function createAsulObjectById(id:String, asulType:Class = null, silent:Boolean = false):DisplayObject

Function provided to make it easier to access graphics objects defined in this ASUL definition files.

Allows the creation of ASUL objects defined in a definition file that has an id (i.e. the object definition has an id).

Parameters
id:String — the id of the element to instantiate.
 
asulType:Class (default = null) — tries to create an ASUL object of the given type, using the localizer and absolute path resolver of this factory.
 
silent:Boolean (default = false) — when set to true, no warning will be logged if the given id is unknown. This can be handy when creating optional elements.

Returns
DisplayObject — a new instance of the element, or null if the element was not defined in the ASUL file (is unknown).
createAsulObjectFromXml()method 
public function createAsulObjectFromXml(xml:XML, applyStylesheet:Boolean = true):DisplayObject

This factory function can be used to create a new ASUL object from some XML data. The actual type is then internally determined and the appropriate instance is created.

This only works with registered classes, i.e. if a new ASUL object is created, it has to manually be added in this function for it to recognize it!

If an unknown element type is given, an exception is thrown.

Parameters
xml:XML — the xml describing the object to create.
 
applyStylesheet:Boolean (default = true) — whether to apply the stylesheet loaded into this factory to the created object directly, or not. This is meant for objects creating their children, and should not be used normally.

Returns
DisplayObject — a new instance of the element, or null if the element's definition was invalid (is unknown).
createTooltip()method 
public function createTooltip(owner:DisplayObject, text:String = ""):ITooltip

Creates a new tooltip using the common TooltipFactory.

This function allows the creation of tooltips in external SWFs that were loaded later on, even though they don't know / have to know the implementation of the tooltip factory.

This creates a new tooltip, using the settings based on the passed owner object. If the owner object is unknown (register new owners with the addStyle() function) the default definition will be used.

Parameters
owner:DisplayObject — the display object for which to create the tooltip.
 
text:String (default = "") — if given, initializes the tool tiptext to this string.

Returns
ITooltip — the created tooltip, or null if the creation failed.

See also

disposeDisplayObject()method 
public function disposeDisplayObject(object:Object, disposeBitmapData:Boolean = false, disposeObject:Boolean = true):void

This function just calls the function of the same name in the de.mightypirates.utils package. By using this function via the interface, external SWFs don't have to be aware of the implementation, though, saving some size. Clean up a display object to make it ready for garbage collection.

If the display object is a container, disposeDisplayObjectContainer is called on the object automatically, meaning this will trigger a recursive disposal of a whole branch of the scene graph, starting with the given node.

Parameters
object:Object — the object to clean up.
 
disposeBitmapData:Boolean (default = false) — whether to dispose bitmap data of found Bitmap objects. This should not be used when having Bitmaps in the scene graph that share their bitmap data with other bitmaps.
 
disposeObject:Boolean (default = true) — whether to call the dispose() method on the object if it implements the IDisposable interface. Can be called with false by classes extending DisplayObject which use this function to clean themselves up without causing infinite recursion.

See also

de.mightypirates.utils.disposeDisplayObject
getAbsPath()method 
public function getAbsPath(path:String):String

A function used to resolve paths from relative to absolute.

Parameters
path:String — the path to convert to an absolute one.

Returns
String — absolute path representation (or the same, if no implementation is set for this).
getAsulDefinitionById()method 
public function getAsulDefinitionById(id:String):XML

Returns the original ASUL definition of the element with the given id.

This can be useful for defining templates that need adjustments at runtime, and which cannot be performed later on (e.g. modifications to a button's states).

Parameters
id:String — the id of the element of which to get the definition.

Returns
XML — the XML definition of the element, or null if no element with such an id known.
hasElementWithId()method 
public function hasElementWithId(id:String):Boolean

Checks if an object with the given id can be instantiated, i.e. if it exists in the factories definition table.

Note: this does not mean the object can be created successfully, it only means the definition is known. There can still be problems caused by invalid attributes, e.g, which are not checked here.

Parameters
id:String — the id of the object.

Returns
Booleantrue if the object is known, else false.
load()method 
public function load(path:String):void

Loads additional definitions from the file at the given location.

Parameters
path:String — the path to the ASUL document to load.

Throws
— exception if there is currently a load in progress.
loadXML()method 
public function loadXML(data:XML):void

Loads additional definitions from the given XML data.

Parameters
data:XML — the XML data being the ASUL document to load.
registerScriptVariable()method 
public function registerScriptVariable(name:String, value:*):void

Registers a variable for the script context of scripts in ASUL files loaded into this factory. If the variable is already existing, it will be overridden!

Parameters
name:String — the name of the variable to register.
 
value:* — the value of the variable to register.
registerVariable()method 
public function registerVariable(name:String, value:Number):void

Registers a variable with its value that can be used in number expressions (when evaluating anchors). This will be passed on to all components created through this factory.

Parameters
name:String — the name of the variable to register.
 
value:Number — the value of the variable to register.