Packagecom.yworks.util
Classpublic class ImageLoader
InheritanceImageLoader Inheritance flash.events.EventDispatcher

Utility class that can be used to load an image from an url. If no Stage object is found, the loader will load the image only if addedToDisplayList is called and a Stage object is found then.



Public Properties
 PropertyDefined By
  image : DisplayObject
The image instance that was loaded by this loader.
ImageLoader
Public Methods
 MethodDefined By
  
ImageLoader(errorFunction:Function = null)
Creates a new ImageLoader.
ImageLoader
  
addedToDisplayList(parent:UIComponent):void
If the load( url ) function was called earlier and the image couldn't be loaded at that time, this method causes the loader to try loading again.
ImageLoader
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void
[override]
ImageLoader
  
load(url:String, swf:Boolean = false):Boolean
Try to load an image from the given url.
ImageLoader
  
loadBase64(base64:String, digest:String = null):void
Creates an image from a base64 encoded String
ImageLoader
Events
 Event Summary Defined By
  Dispatched when the image has been loaded.ImageLoader
Property Detail
imageproperty
image:DisplayObject

The image instance that was loaded by this loader. If the image was loaded correctly, this will usually be a com.yworks.util.CloneableBitmap instance.


Implementation
    public function get image():DisplayObject
    public function set image(value:DisplayObject):void
Constructor Detail
ImageLoader()Constructor
public function ImageLoader(errorFunction:Function = null)

Creates a new ImageLoader.

Parameters
errorFunction:Function (default = null) — A function that is executed when loading fails.
Method Detail
addedToDisplayList()method
public function addedToDisplayList(parent:UIComponent):void

If the load( url ) function was called earlier and the image couldn't be loaded at that time, this method causes the loader to try loading again. Whether the loader actually tries to load the image depends on whether a Stage object is found using the given UIComponent. When loading has completed successfully, the "complete" event will be fired.

Parameters

parent:UIComponent

addEventListener()method 
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0.0)
 
useWeakReference:Boolean (default = false)

load()method 
public function load(url:String, swf:Boolean = false):Boolean

Try to load an image from the given url. If the image is already contained in the com.yworks.util.BitmapCache, it won't be loaded again. If no Stage object can be found, the loading will be delayed until addedToDisplayList is called. When loading has completed successfully, the "complete" event will be fired.

Parameters

url:String — The url to load the image from.
 
swf:Boolean (default = false) — whether the file located at the given url is a swf file. This parameter is deprecated.

Returns
Booleantrue, if loading could be started. false, if addedToDisplayList will have to be called to actually load the image.
loadBase64()method 
public function loadBase64(base64:String, digest:String = null):void

Creates an image from a base64 encoded String

Parameters

base64:String — The base64 encoded String
 
digest:String (default = null) — Key for the BitmapCache. If none is provided, the SHA1 checksum of the base64 String is used.

Event Detail
complete Event
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE

Dispatched when the image has been loaded.