Packagecom.developmentarc.framework.utils
Classpublic class LocalConnectionManager
InheritanceLocalConnectionManager Inheritance flash.events.EventDispatcher

The LocalConnectionManager provides a simpler interface to the Flash LocalConnection that is designed to support retention of Class type when communication with other ActionScript 3 Applications. For Class retention to work both Application must contain the custom class. If the class does not existing in the receiving Application an error event will be dispatched.

To use this utility create a new instance of the Class providing the target Object that methods send from another LocalConnection should be applied to, create a connection to expose this application to other LCM enabled applications and then brodacast messages with sendMessage() method.



Public Properties
 PropertyDefined by
  connected : Boolean
[read-only] Used to determine of the LocalConnectionManager has an active connection.
LocalConnectionManager
Protected Properties
 PropertyDefined by
  connection : LocalConnection
Stores the LC instance for the Class.
LocalConnectionManager
  connectionTarget : Object
Stores the connection target object that should be called when a message from the LC is received.
LocalConnectionManager
  currentConnectionName : String
Stores the connection name for the current application for communication.
LocalConnectionManager
  currentDomainList : Array
Stores the current domain list that was defined at construction.
LocalConnectionManager
Public Methods
 MethodDefined by
  
LocalConnectionManager(connTarget:Object, connectionName:String, domainList:Array = null, autoConnect:Boolean = true)
Constructor.
LocalConnectionManager
  
addDomain(domainArray:Array):void
Updates the approved domain list on the LocalConnection.
LocalConnectionManager
  
connect(connectionName:String, domainList:Array = null):void
Used to connect to a local connection name.
LocalConnectionManager
  
disconnect():void
Ends the current local conenction session and removes all handlers so that Garbage collection can occur.
LocalConnectionManager
  
sendMessage(target:String, methodName:String, ... args):void
Calls the application via the target name and method defined in the arguments.
LocalConnectionManager
Protected Methods
 MethodDefined by
  
handleAsyncEvent(event:AsyncErrorEvent):void
Used to track Async errors from the LC instance.
LocalConnectionManager
  
handleStatusEvent(event:StatusEvent):void
Used to track Status events from the LC instance.
LocalConnectionManager
Events
 EventSummaryDefined by
    LocalConnectionManager
    LocalConnectionManager
    LocalConnectionManager
Property detail
connectedproperty
connected:Boolean  [read-only]

Used to determine of the LocalConnectionManager has an active connection.

Implementation
    public function get connected():Boolean
connectionproperty 
protected var connection:LocalConnection

Stores the LC instance for the Class.

connectionTargetproperty 
protected var connectionTarget:Object

Stores the connection target object that should be called when a message from the LC is received.

currentConnectionNameproperty 
protected var currentConnectionName:String

Stores the connection name for the current application for communication.

currentDomainListproperty 
protected var currentDomainList:Array

Stores the current domain list that was defined at construction.

Constructor detail
LocalConnectionManager()constructor
public function LocalConnectionManager(connTarget:Object, connectionName:String, domainList:Array = null, autoConnect:Boolean = true)

Constructor. Creates a new instance of a LCM and establishes the LocalConnection instance during construction.

The constructor also opens the application for communication with other LCM enabled applications based on the name provided. For other LCM enabled apps to successfully communicate the app must be on an approved domain and know the name that is defined for this application. Only one application at a time can be connected via the provided name. If an application is already connected via this name the LCM will dispatch a LocalConnectionEvent.CONNECTION_ERROR. If a connection name is not provided then the two error communication will not be able to function, this is why the argument is required.

Parameters
connTarget:Object — This is the object that LC message calls are applied to when received from another applicaiton.
 
connectionName:String — The application communication name
 
domainList:Array (default = null) — An array of domains to allow communication with the LC, if no value is set the default is '.
 
autoConnect:Boolean (default = true) — Determines if the manager should attempt to auto connect on construction.
Method detail
addDomain()method
public function addDomain(domainArray:Array):void

Updates the approved domain list on the LocalConnection.

Parameters
domainArray:Array — A list of strings that represent the allowed domains.
connect()method 
public function connect(connectionName:String, domainList:Array = null):void

Used to connect to a local connection name. If the local connection is not connected this method creates a new connection and connects to the name provided. If a name is not provided the default name defined at the construction is used or the last name called via the connect method.

If a connection is currently established, this method disconnects from the exisiting connection and creates a new connection.

Parameters
connectionName:String
 
domainList:Array (default = null)
disconnect()method 
public function disconnect():void

Ends the current local conenction session and removes all handlers so that Garbage collection can occur.

handleAsyncEvent()method 
protected function handleAsyncEvent(event:AsyncErrorEvent):void

Used to track Async errors from the LC instance.

Parameters
event:AsyncErrorEvent — AsyncEvent thrown by the LC.
handleStatusEvent()method 
protected function handleStatusEvent(event:StatusEvent):void

Used to track Status events from the LC instance.

Parameters
event:StatusEvent — Status event from the LC.
sendMessage()method 
public function sendMessage(target:String, methodName:String, ... args):void

Calls the application via the target name and method defined in the arguments. This method retains the Class definitions and marks the arguments according to their type so that the receiving application can re-cast back to the correct Class. The receiving application must have the same defined type and the method argument count must match both order and type in order for the call to be successfully completed.

Parameters
target:String — The name of the application exposed via connectionName to call the method on.
 
methodName:String — The method to call on the target application.
 
... args — Common seperated argument values for the defined method.
Event detail
connectionErrorevent 
Event object type: com.developmentarc.framework.utils.events.LocalConnectionEvent

sentMessageErrorevent  
Event object type: com.developmentarc.framework.utils.events.LocalConnectionEvent

statusMessageevent  
Event object type: com.developmentarc.framework.utils.events.LocalConnectionEvent