Packagefeathers.utils.textures
Classpublic class TextureCache
InheritanceTextureCache Inheritance Object

Product Version : Feathers 2.3.0

Caches textures in memory. Each texture may be saved with its own key, such as the URL where the original image file is located.

Note: Most developers will only need to create a TextureCache, pass it to multiple ImageLoader components, and dispose the cache when finished. APIs to retain and release textures are meant to be used by ImageLoader.

A single TextureCache may be passed to multiple ImageLoader components using the textureCache property:

var cache:TextureCache = new TextureCache();
loader1.textureCache = cache;
loader2.textureCache = cache;

Don't forget to dispose the TextureCache when it is no longer needed -- to avoid memory leaks:

cache.dispose();

To use a TextureCache in a List or GroupedList with the default item renderer, pass the cache to the ImageLoader components using the iconLoaderFactory or accessoryLoaderFactory:

var cache:TextureCache = new TextureCache();
list.itemRendererFactory = function():IListItemRenderer
{
    var itemRenderer:DefaultListItemRenderer = new DefaultListItemRenderer();
    itemRenderer.iconLoaderFactory = function():ImageLoader
    {
        var loader:ImageLoader = new ImageLoader();
        loader.textureCache = cache;
        return loader;
    };
    return itemRenderer;
};

See also

feathers.controls.ImageLoader.textureCache


Public Properties
 PropertyDefined By
  maxUnretainedTextures : int
Limits the number of unretained textures that may be stored in memory.
TextureCache
Public Methods
 MethodDefined By
  
TextureCache(maxUnretainedTextures:int)
Constructor.
TextureCache
  
addTexture(key:String, texture:Texture, retainTexture:Boolean = true):void
Saves a texture, and associates it with a specific key.
TextureCache
  
dispose():void
Disposes the texture cache, including all textures (even if they are retained).
TextureCache
  
getRetainCount(key:String):int
Returns how many times the texture associated with the specified key has currently been retained.
TextureCache
  
hasTexture(key:String):Boolean
Indicates if a texture is associated with the specified key.
TextureCache
  
releaseTexture(key:String):void
Releases a retained texture.
TextureCache
  
removeTexture(key:String, dispose:Boolean = false):void
Removes a specific key from the cache, and optionally disposes the texture associated with the key.
TextureCache
  
retainTexture(key:String):Texture
Gets the texture associated with the specified key, and increments the retain count for the texture.
TextureCache
Property Detail
maxUnretainedTexturesproperty
maxUnretainedTextures:int

Limits the number of unretained textures that may be stored in memory. The textures retained least recently will be disposed if there are too many.


Implementation
    public function get maxUnretainedTextures():int
    public function set maxUnretainedTextures(value:int):void
Constructor Detail
TextureCache()Constructor
public function TextureCache(maxUnretainedTextures:int)

Constructor.

Parameters
maxUnretainedTextures:int (default = NaN)
Method Detail
addTexture()method
public function addTexture(key:String, texture:Texture, retainTexture:Boolean = true):void

Saves a texture, and associates it with a specific key.

Parameters

key:String
 
texture:Texture
 
retainTexture:Boolean (default = true)

See also

dispose()method 
public function dispose():void

Disposes the texture cache, including all textures (even if they are retained).

getRetainCount()method 
public function getRetainCount(key:String):int

Returns how many times the texture associated with the specified key has currently been retained.

Parameters

key:String

Returns
int
hasTexture()method 
public function hasTexture(key:String):Boolean

Indicates if a texture is associated with the specified key.

Parameters

key:String

Returns
Boolean
releaseTexture()method 
public function releaseTexture(key:String):void

Releases a retained texture.

Parameters

key:String

See also

removeTexture()method 
public function removeTexture(key:String, dispose:Boolean = false):void

Removes a specific key from the cache, and optionally disposes the texture associated with the key.

Parameters

key:String
 
dispose:Boolean (default = false)

See also

retainTexture()method 
public function retainTexture(key:String):Texture

Gets the texture associated with the specified key, and increments the retain count for the texture. Always remember to call releaseTexture() when finished with a retained texture.

Parameters

key:String

Returns
Texture

See also