nl.stroep.utils.Image (2)

, under actionscript, Code snippets.

Code snippetEasily create an image without taking care of loaders and URLRequest etc.
Most simple usage of the Image class:
[as]import nl.stroep.utils.Image

var myImage:Image = new Image(“myImage.jpg”);
this.addChild(myImage)
[/as]You can also add the most common eventListeners to the image:
[as]import nl.stroep.utils.Image

var myImage:Image = new Image(“myImage.jpg”);
this.addChild(myImage);

myImage.addEventListener(Event.COMPLETE, onImageLoaded );
myImage.addEventListener(IOErrorEvent.IO_ERROR, onImageError );
myImage.addEventListener(ProgressEvent.PROGRESS, onImageLoading );

function onImageLoaded (e:Event):void {
trace(“image loaded!”);
}

function onImageError (e:IOErrorEvent):void {
trace(“image error”, e.text);
}

function onImageLoading (e:ProgressEvent):void {
trace(“loading image.. bytesLoaded=” + e.bytesLoaded + ” bytesTotal=” + e.bytesTotal );
}
[/as]

Download
Check out the Image class at googlecode

2 responses to “nl.stroep.utils.Image”

  1. Jack says:

    Thanks for the great utility.

    I was going to create some high resolution images but it seems that it doesn’t work past a certain size. Any tips on how I would go about creating high resolution images?

    Cheers

Say something interesting

Please link to code from an external resource, like gist.github.com.