| Package | qnx.utils |
| Class | public class ImageCache |
| Inheritance | ImageCache flash.events.EventDispatcher |
ImageCache class provides image caching functionality for your application.
The class can be used in conjuction with the Image component class.
See also
| Property | Defined By | ||
|---|---|---|---|
| cacheSize : int
Gets or sets the cache size for your image cache given an integer representing the number of images to cache. | ImageCache | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new ImageCache instance. | ImageCache | ||
addImageData(url:String, data:BitmapData):void
Updates the bitmap image data for an element in the cache given a URL to the image and new bitmap data. | ImageCache | ||
clear(force:Boolean = false):void
Clear the image cache and disposes the BitmapData. | ImageCache | ||
getImage(url:String, load:Boolean):BitmapData
Returns an image from the cache, given the URL of the image and a Boolean that determines whether or not
to load the image from the URL provided. | ImageCache | ||
reloadImage(url:String):void
Reloads an image from the cache given the URL to the image. | ImageCache | ||
unlock(url:String):void
Unlocks an image in the cache, given a URL to the image. | ImageCache | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when an image has loaded. | ImageCache | |||
| Dispatched when an image has failed to load. | ImageCache | |||
| cacheSize | property |
cacheSize:intGets or sets the cache size for your image cache given an integer representing the number of images to cache.
The default value is .Number.POSITIVE_INFINITY
public function get cacheSize():int public function set cacheSize(value:int):void| ImageCache | () | Constructor |
public function ImageCache()
Creates a new ImageCache instance.
| addImageData | () | method |
public function addImageData(url:String, data:BitmapData):voidUpdates the bitmap image data for an element in the cache given a URL to the image and new bitmap data.
This method will dispatch an ImageCacheEvent.IMAGE_LOADED event, so listeners can update automatically.
Parameters
url:String — The URL to the image.
| |
data:BitmapData — The new bitmap data for the image.
|
| clear | () | method |
public function clear(force:Boolean = false):voidClear the image cache and disposes the BitmapData.
Parameters
force:Boolean (default = false) — If true ALL images will be disposed, including one whch may be on the stage, if false only unlocked images will be disposed
|
| getImage | () | method |
public function getImage(url:String, load:Boolean):BitmapDataReturns an image from the cache, given the URL of the image and a Boolean that determines whether or not to load the image from the URL provided.
If the image is in the cache it is locked before it is returned. It must be unlocked when no longer in use.
Parameters
url:String — The URL to the image.
| |
load:Boolean — A Boolean indicating whether or not to load the image.
|
BitmapData — The Image as BitmapData.
|
| reloadImage | () | method |
public function reloadImage(url:String):voidReloads an image from the cache given the URL to the image.
If the image is not in the cache nothing is done.
Parameters
url:String — The URL to the image.
|
| unlock | () | method |
public function unlock(url:String):voidUnlocks an image in the cache, given a URL to the image.
An unlocked image can be flushed from cache if space is required.
Parameters
url:String — The URL to the image.
|
| imageLoaded | Event |
qnx.events.ImageCacheEventqnx.events.ImageCacheEvent.IMAGE_LOADEDDispatched when an image has loaded.
See also
| imageLoadError | Event |
qnx.events.ImageCacheEventqnx.events.ImageCacheEvent.IMAGE_LOAD_ERRORDispatched when an image has failed to load.
See also