ActionScript Reference
_aspRatio
_customLoader
_fileLoadedHandler
_imageVA
_imageHA
_loaderHandler
_loaderHA
_loaderVA
_percentLoaded
_scaleToFit
imageURL
_loaderClr
_imageWidth
_imageHeight
loadImage
getImageBytesLoaded
getImageBytesTotal
a Booloean value that indicates whether the image specified by the loadImage parameter will maintain its aspect ratio. _aspRatio property is available for use only if _scaleToFit is set to true. The default value is true.
myImage._aspRatio
A booloean value which indicates whether the image specified by the loadImage parameter will scale to the Image Loader movieClip bounds. The default value is true.
myImage._scaleToFit
A Booloean value which indicates whether the custom loader handler is active or not. If this property is disabled (false) the <i>_loaderHandler</i> will be ignored. The default value is false.
myImage._customLoader
Executes the defined function. You can use this handler if you want to create a custom preloader for your Image Loader. Will be executed only if the _customLoader is set to true.
Note: In the live preview, the imageLoader always uses the default loader bar.
myImage._loaderHandler="loader" (where "loader" is the name of the _loaderHandler function)
Example:
The following code defines a custom loader handler:
myImage._customLoader=true
myLoader=function(image){
if(image.getImageBytesLoaded>=image.getImageBytesTotal){
trace(image.imageURL+" has loaded successfully!")
}
trace("Loading...")
}
myImage._loaderHandler="myLoader"
Indicates the horizontal alignment of the image, represented as a string. If "left", the image is left-aligned. If "center", the image is centered. If "right", the prelaoder is right-aligned. The default value is "left".
myImage._imageHA
Indicates the vertical alignment of the image, represented as a string. If "top", the image is top-aligned. If "center", the image is centered. If "bottom", the prelaoder is bottom-aligned. The default value is "top".
myImage._imageVA
Indicates the horizontal alignment of the preloader, represented as a string. If "left", the preloader is left-aligned. If "center", the preloader is centered. If "right", the prelaoder is right-aligned. The default value is "left".
myImage._loaderHA
Indicates the vertical alignment of the preloader, represented as a string. If "top", the preloader is top-aligned. If "center", the preloader is centered. If "bottom", the prelaoder is bottom-aligned. The default value is "top".
myImage._loaderVA
Retrieves the percentage of the image loaded. Works within _loaderHandler or _fileLoadedHandler
myImage._percentLoaded
Example:
The following code defines a custom loader handler and traces the percentage of the loaded item:
myImage._customLoader=true
myLoader=function(image){
if(image.getImageBytesLoaded>=image.getImageBytesTotal){
trace(image+" has loaded successfully!")
}
trace(image._percentLoaded+"% loaded...")
}
myImage._loaderHandler="myLoader"
Executes the defined function. You can use this handler to invoke some actions when the image is loaded.
myImage._fileLoadedHandler="loaded" (where "loaded" is the name of the _fileLoadedHandler function)
imageURL
Retrieves the image URL (read-only).
myImage.imageURL
Returns: Image URL
Defines the color of the default imageLoader loading bar.
myImage._loaderClr
Example:
The following code will load image "my_image.jpg" in attached movie "myImage". The loader bar will be red.
var initObj = {
imageURL:"my_image.jpg",
_loaderClr:"#ff0000"
};
_root.attachMovie("ImageLoader", "myImage", 1, initObj);
Retrieves the image width of the loaded image.
myImage._imageWidth
Example:
The following code will load image "my_image.jpg" in attached movie "myImage". When image is loaded, it's width will be displayed in output window
myImage._customLoader=true;
myLoader=function(image){
this.onEnterFrame = function(){
if(image._status){
trace(image+" width is "+image._imageWidth);
delete this.onEnterFrame;
}
trace("Loading...")
}
myImage._customLoader=true;
myImage._loaderHandler="myLoader";
Retrieves the image height of the loaded image.
myImage._imageHeight
Example:
The following code will load the image "my_image.jpg" into the attached movie "myImage". When the image is loaded, its height will be displayed in the output window:
myImage._customLoader=true;
myLoader=function(image){
this.onEnterFrame = function(){
if(image._status){
trace(image+" height is "+image._imageHeight)
delete this.onEnterFrame
}
trace("Loading...");
}
myImage._customLoader=true;
myImage._loaderHandler="myLoader";
loadImage
loads SWF or JPEG files. This is very similar to the loadMovie method. If you are planning to use absolute URLs, please note that the livePreview of the component will not work correctly.
myImage.loadImage("my_image.jpg")
Returns the number of bytes loaded (streamed) for the specified imageLoader object. You can compare the value of the getImageBytesLoaded method with the value of the getImageBytesTotal method to determine the percentage that an image has loaded.
Note: You can use this method only within the ImageLoader handlers.
myLoader=function(image){
this.onEnterFrame = function(){
if(image.getImageBytesLoaded>=image.getImageBytesTotal){
delete this.onEnterFrame
}
trace("loaded = "+image.getImageBytesLoaded)
}
}
myImage._loaderHandler = "myLoader"
The example above will trace the number of bytes loaded until they reach the number of total loaded bytes.
getImageBytesTotal
An integer indicating the total size, in bytes, of the image loaded (similar to getBytesTotal)
Returns the size, in bytes, of the specified imageLoader.
Note: You can use this method only within the ImageLoader handlers.
myLoader=function(image){
this.onEnterFrame = function(){
if(image.getImageBytesLoaded>=image.getImageBytesTotal){
delete this.onEnterFrame
}
trace("bytes to be loaded = "+image.getImageBytesTotal+newline+"bytes loaded = "+image.getImageBytesLoaded)
}
}
myImage._loaderHandler = "myLoader"
The example above will trace the number of bytes loaded and the toal number of bytes to be loaded.