Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
InstanceCache is a utility that governs the task of creating and managing
a set of
n object instances, where
n changes frequently.
count:int
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
The number of items currently required in the cache.
Implementation public function get count():int
public function set count(value:int):void
public var creationCallback:Function
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
A callback invoked when new instances are created.
This callback has the following signature:
function creationCallback(newInstance:Object, cache:InstanceCache):void;
public var discard:Boolean = false
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Determines if unneeded instances are discarded.
If set to true
, extra elements are discarded
when the cache count is reduced.
Otherwise, extra elements are kept in a separate cache
and reused when the count is increased.
factory:IFactory
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
A factory that generates the type of object to cache.
Assigning to this discards all current instances
and recreate new instances of the correct type.
Implementation public function get factory():IFactory
public function set factory(value:IFactory):void
format:flash.text:TextFormat
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
A TextFormat to apply to any instances created.
If set, this format is applied as the current and default format
for the contents of any instances created.
This property is only relevant if the factory
generates TextField instances.
Implementation public function get format():flash.text:TextFormat
public function set format(value:flash.text:TextFormat):void
public var hide:Boolean = true
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Determines if unneeded instances should be hidden.
If true
, the visible
property
is set to false
on each extra element
when the cache count is reduced, and set to true
when the count is increased.
This property is only relevant when the factory
generates DisplayObjects.
Setting this property to true
for other factory types
generates a run-time error.
insertPosition:int
[write-only]
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
The position of the instance in the parent's child list.
Implementation public function set insertPosition(value:int):void
instances:Array
[read-only]
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
The Array of cached instances.
There may be more instances in this Array than currently requested.
You should rely on the count
property
of the instance cache rather than the length of this Array.
Implementation public function get instances():Array
properties:Object
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
A hashmap of properties to assign to new instances.
Each key/value pair in this hashmap is assigned
to each new instance created.
The property hashmap is assigned to any existing instances when set.
The values in the hashmap are not cloned;
object values are shared by all instances.
Implementation public function get properties():Object
public function set properties(value:Object):void
public var remove:Boolean = false
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Determines if unneeded instances should be removed from their parent.
If true
, the removeChild()
method
is called on the parent for each extra element
when the cache count is reduced.
This property is only relevant when the factory
generates DisplayObjects.
Setting this property to true
for other factory types
generates a run-time error.
public function InstanceCache(type:Object, parent:Object = null, insertPosition:int = -1)
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Constructor.
Parameters | type:Object — The type of object to construct.
This can be either a Class or an IFactory.
|
|
| parent:Object (default = null ) — An optional DisplayObject to add new instances to.
|
|
| insertPosition:int (default = -1 ) — Where in the parent's child list
to insert instances. Set to -1 to add the children to the end of the child list.
|