Class com.asual.enflash.EnFlashObject

com.asual.enflash.EnFlashObject

Description

EnFlashObject is the base class of the EnFlash Framework. It provides object identification, hierarchical referencing, event handling and XML serialization/deserialization.

Field Index

id, oninit, onremove, parent, ref

Method Index

new EnFlashObject()

addEventListener(), createDelegate(), debug(), dispatchEvent(), dispatchEventOnce(), getListeners(), getXML(), main(), remove(), removeDelegate(), removeEventListener(), setXML(), toString()

Constructor Detail

EnFlashObject

public function EnFlashObject(id:String)
Parameters
id - (optional) Descriptive ID of this object.

Field Detail

oninit

public oninit:Function

Event that notifies when this object is initialized.


onremove

public onremove:Function

Event that notifies when this object is removed.


id

public id:String [Read Only]

The ID of this object


parent

public parent:Object [Read Only]

The parent of this object


ref

public ref:Number [Read Only]

The reference number of this object that is used in the EnFlash hierarchy.

Method Detail

toString

public function toString():String
Basic method that returns the type of this object.
Return
The type of this object

main

public function main(parent:Number):Void
Initializes this object and makes it part of the EnFlash hierarchy.
Parameters
parent - Parent's reference

getXML

public function getXML():XMLNode
Generates an XML structure that contains all the information available for this object.
Return
XML representation of this object

setXML

public function setXML(xml:XMLNode):Void
Loads an XML structure that contains public properties, event listeners and inline objects.
Parameters
xml - XML represantation of this object

addEventListener

public function addEventListener(type:String, object:Object, method:Function, args:Object):Void
Adds event specific listeners to this object.
Example: addEventListener("init", myObject, myObject.methodName, {neededObject: someObject});
Parameters
type - Event type
object - The object that will listen for the event
method - The method that will be invoked when the event is dispached
args - (optional) Additional object with custom properties that will be received by the listener

removeEventListener

public function removeEventListener(type:String, object:Object, method:Function):Void
Removes event specific listeners from this object.
Example: removeEventListener("init", myObject);
Parameters
type - Event type
object - The object that will be removed from the listeners collection
method - (optional) Method reference that specifies exactly which couple of object/method has to be removed. This can be used when an object listens for specific event with multiple methods

dispatchEvent

public function dispatchEvent(type:String, params:Object):Void
Dispatches event to all available listeners.
Example: dispatchEvent("init", object1, object2.someProperty,...objectN);
Parameters
type - Event type
params - (optional) Additional event specific parameters

dispatchEventOnce

public function dispatchEventOnce(object:Object, type:String, params:Object):Void
Dispatches event to a single listener.
Example: dispatchEventOnce(listenerObject, "init", object1, object2.someProperty,...objectN);
Parameters
object - Known listener object
type - Event type
params - (optional) Additional event event specific parameters

getListeners

public function getListeners(type:String):Array
Provides a list of event specific listeners.
Parameters
type - Event type
Return
Array of objects with 3 properties: object, method and arguments

createDelegate

public function createDelegate(object:Object, method:Function, args:Object):Function
Creates a delegate for an event that will be handled in the specified scope. This method is useful when working with Flash's build-in objects.
Parameters
object - The object that provides a scope for the event execution
method - Method reference that will handle the event
args - (optional) Object containing custom properties that will be passed together with the event
Return
Delegate function

removeDelegate

public function removeDelegate(object:Object, method:Function):Void
Removes a previously created delegate.
Parameters
object - Object that has a method with an assigned Delegate
method - The method that is binded to a Delegate that has to be removed

debug

public function debug(msg:String):Void
Displays program messages in a top-level Label instance.
Example: debug("myObject", myObject,...myObject.someProperty);
Parameters
msg - One or multiple objects and values to be displayed.

remove

public function remove():Void
Removes this object from the application.