Stroep

Just a collection of random works – Mark Knol

Tag Archives: 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");
this.addChild(myImage)
 

You can also add the most common eventListeners to the image:

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 :P rogressEvent):void {
   trace("loading image.. bytesLoaded=" + e.bytesLoaded + " bytesTotal=" + e.bytesTotal );
}
 

Download
Check out the Image class at googlecode

Tagged with , , , .

Code snippetClass to work/calculate with colors. You can easily abstract the red, green or blue values from a color.

Usage:

import nl.stroep.utils.Color

// create orange color
var myColor:Color = new Color(0xFFCC00);

trace("value", myColor.value);
trace("red", myColor.red);
trace("green ", myColor.green);
trace("blue", myColor.blue);
 

Download
Check out the Color class at googlecode

Tagged with , , .