Packagecom.joebillman.utils
Classpublic class ObjectPool
InheritanceObjectPool Inheritance Object

ObjectPool: This a useful class for creating objects that will be used over and over. Instantiation only occurs once per object.

View the examples



Public Methods
 MethodDefined By
  
ObjectPool(type:Class, amount:int, stopMCsOnCreation:Boolean = false, stopMCsOnDestruction:Boolean = false)
Constructor.
ObjectPool
  
destroy():void
Destroys the objects array by setting it to null.
ObjectPool
  
Gets a reference to the objects array.
ObjectPool
  
getObject():DisplayObject
Gets an available item from the pool.
ObjectPool
  
returnObject(obj:DisplayObject):void
Returns an item to the pool.
ObjectPool
Constructor Detail
ObjectPool()Constructor
public function ObjectPool(type:Class, amount:int, stopMCsOnCreation:Boolean = false, stopMCsOnDestruction:Boolean = false)

Constructor.

Parameters
type:Class
 
amount:int
 
stopMCsOnCreation:Boolean (default = false)
 
stopMCsOnDestruction:Boolean (default = false)
Method Detail
destroy()method
public function destroy():void

Destroys the objects array by setting it to null.

getAllObjects()method 
public function getAllObjects():Array

Gets a reference to the objects array. This is useful for performing individual item cleanup.

Returns
Array
getObject()method 
public function getObject():DisplayObject

Gets an available item from the pool.

Returns
DisplayObject
returnObject()method 
public function returnObject(obj:DisplayObject):void

Returns an item to the pool.

Parameters

obj:DisplayObject

Examples
The following example.

Note: Details

     var enemyPool:ObjectPool = new ObjectPool(Enemy, 25);