|
Download Object PoolTwo 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.
|
look cool