Packagecom.asfusion.mate.core
Classpublic class Cache
InheritanceCache Inheritance flash.utils.Proxy
Implementsflash.events.IEventDispatcher, ISmartObject

The Cache allows getting cached objects within the event map's IActionList.



Public Properties
 PropertyDefined by
  generatorKey : Class
A key used as index to get the cached objects.
Cache
Protected Properties
 PropertyDefined by
  autoCreate : Boolean
Whether we create a new instance of the object when we don't find one in the cache.
Cache
  cacheType : String
The cacheType property lets you specify whether we should use a local or cache.
Cache
  chain : Array = null
A list of properties that has been accessed using the dot operator.
Cache
  constructorArguments : Array
The constructorArgs allows you to pass an Array of objects to the contructor when the instance is created.
Cache
  registerTarget : Boolean
Registers the newly created object as an injector target.
Cache
Public Methods
 MethodDefined by
  
Cache(key:Class, cacheType:String, autoCreate:Boolean = false, registerTarget:Boolean = false, constructorArguments:Array = null)
Constructor
Cache
  
addCachedInstance(key:*, instance:Object, type:String, scope:IScope):void
[static] Stores an instance in the cache.
Cache
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, weakRef:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
Cache
  
addKey(chain:Array, key:String):void
Cache
  
clearCachedInstance(key:*, type:String, scope:IScope):*
[static] Removes an instance from the cache.
Cache
  
dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow.
Cache
  
getCachedInstance(key:*, type:String, scope:IScope):Object
[static] Get an instance from the cache.
Cache
  
getValue(scope:IScope, debugCall:Boolean = false):Object
This method returns the real value of the SmartObject
Cache
  
hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
Cache
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
Cache
  
willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
Cache
Protected Methods
 MethodDefined by
  
getProperty(name:*):*
Overrides any request for a property's value.
Cache
Public Constants
 ConstantDefined by
  GLOBAL : String = "global"
[static] Global cache
Cache
  INHERIT : String = "inherit"
[static] Use same cache type that is defined in the EventMap.
Cache
  LOCAL : String = "local"
[static] Local cache, it is the one that lives in the EventMap
Cache
  NONE : String = "none"
[static] Does not use cache.
Cache
Property detail
autoCreateproperty
protected var autoCreate:Boolean

Whether we create a new instance of the object when we don't find one in the cache.

cacheTypeproperty 
protected var cacheType:String

The cacheType property lets you specify whether we should use a local or cache.

chainproperty 
protected var chain:Array = null

A list of properties that has been accessed using the dot operator. For example, if you a access an inner property like this: myObject.property1.property2, the chain is equivalent to an array with 2 items [property1,property2]

constructorArgumentsproperty 
protected var constructorArguments:Array

The constructorArgs allows you to pass an Array of objects to the contructor when the instance is created.

generatorKeyproperty 
generatorKey:Class  [read-write]

A key used as index to get the cached objects. The Class name is the key used to cach objects.

This property can be used as the source for data binding.

Implementation
    public function get generatorKey():Class
    public function set generatorKey(value:Class):void
registerTargetproperty 
protected var registerTarget:Boolean

Registers the newly created object as an injector target. If true, this allows this object to be injected with properties using the Injectors tags.

Constructor detail
Cache()constructor
public function Cache(key:Class, cacheType:String, autoCreate:Boolean = false, registerTarget:Boolean = false, constructorArguments:Array = null)

Constructor

Parameters
key:Class
 
cacheType:String
 
autoCreate:Boolean (default = false)
 
registerTarget:Boolean (default = false)
 
constructorArguments:Array (default = null)
Method detail
addCachedInstance()method
public static function addCachedInstance(key:*, instance:Object, type:String, scope:IScope):void

Stores an instance in the cache. The cache can be local, global or inherit. The key that we use to store the instance is the class of the object that we want to store.

Parameters
key:*
 
instance:Object
 
type:String
 
scope:IScope
addEventListener()method 
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, weakRef:Boolean = false):void

Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority.

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
weakRef:Boolean (default = false)
addKey()method 
public function addKey(chain:Array, key:String):void

Parameters
chain:Array
 
key:String
clearCachedInstance()method 
public static function clearCachedInstance(key:*, type:String, scope:IScope):*

Removes an instance from the cache. The cache can be local, global or inherit. The key used is the class of the object that we want to removed.

Parameters
key:*
 
type:String
 
scope:IScope

Returns
*
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called.

Parameters
event:Event

Returns
Boolean
getCachedInstance()method 
public static function getCachedInstance(key:*, type:String, scope:IScope):Object

Get an instance from the cache. The cache can be local, global or inherit. The key used is the class of the object that we want to access.

Parameters
key:*
 
type:String
 
scope:IScope

Returns
Object
getProperty()method 
flash_proxy override function getProperty(name:*):*

Overrides any request for a property's value. If the property can't be found, the method returns undefined. For more information on this behavior, see the ECMA-262 Language Specification, 3rd Edition, section 8.6.2.1.

Parameters
name:*

Returns
*
getValue()method 
public function getValue(scope:IScope, debugCall:Boolean = false):Object

This method returns the real value of the SmartObject

Parameters
scope:IScope
 
debugCall:Boolean (default = false)

Returns
Object
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger().

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

Parameters
type:String

Returns
Boolean
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
willTrigger()method 
public function willTrigger(type:String):Boolean

Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. This method returns true if an event listener is triggered during any phase of the event flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants.

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

Parameters
type:String

Returns
Boolean
Constant detail
GLOBALconstant
public static const GLOBAL:String = "global"

Global cache

INHERITconstant 
public static const INHERIT:String = "inherit"

Use same cache type that is defined in the EventMap. Can be either local or global

LOCALconstant 
public static const LOCAL:String = "local"

Local cache, it is the one that lives in the EventMap

NONEconstant 
public static const NONE:String = "none"

Does not use cache.