My favorites | Sign in
Project Logo
             
Search
for
Updated Oct 07, 2008 by bigroom.co.uk
ObjectPool  
Manages object pooling by retaining disposed objects and returning them when a new object is requested

Download

Object Pool

Two of the slowest operations in the flash player are object creation and garbage collection. If we pool objects - save objects when they're no longer needed and reuse them later when another object of the same type is required - then object creation is kept to a minimum and the garbage collector will never operate.

This object pool class manages polling of all objects. You can obtain an object from it like this

var obj:SomeClass = ObjectPool.getObject( SomeClass );

If there are any such objects in the pool, one of them will be returned. If there are no such objects in the pool, a new one will be created and returned to you.

You can add an object to the pool for later reuse like this

ObjectPool.disposeObject( obj );

The object doesn't have to have been created through the pool - any object can be dropped into the pool with the disposeObject method.


Comment by cpcheats101, Oct 31, 2008

look cool


Sign in to add a comment
Hosted by Google Code