topical media & game development
actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-Image.ax
actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-Image.ax
[swf]
flex
package
{
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.EventDispatcher;
//import com.example.programmingas3.asciiArt.AsciiArtBuilder;
Represents a loadable image and metadata about that image.
public class @ax-actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-Image extends EventDispatcher
{
// ------- Private vars -------
private var _loader:Loader;
//
// ------- Constructor -------
//
public function @ax-actionscript-book-ASCIIArt-com-example-programmingas3-asciiArt-Image(imageInfo:@fileInfo)
{
this.info = imageInfo;
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
}
// ------- Public Properties -------
public var info:@fileInfo;
// ------- Public Methods -------
public function getBitmapData():BitmapData
{
return Bitmap(_loader.content).bitmapData;
}
Loads the image file associated with this instance.
public function load():void
{
var request:URLRequest = new URLRequest(actionscript_book_ASCIIArt_com_example_programmingas3_asciiArt_AsciiArtBuilder.IMAGE_PATH + info.fileName);
_loader.load(request);
}
// ------- Event Handling -------
Called when the image associated with this instance has completely loaded. In essence
it passes the event along to any listeners which have subscribed with this instance.
private function completeHandler(event:Event):void
{
dispatchEvent(event);
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.