ActionScript, Code snippets

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

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

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

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 );

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?


Say something interesting

Please link to code from an external resource, like