[solved]Image loading problem
Code:
private function getImage():void
{
fr.addEventListener(Event.SELECT,imgLoad);
fr.addEventListener(Event.COMPLETE,imgExtract);
fr.browse([new FileFilter("Images(*.png,*.jpg,*.bmp)","*.png;*.jpg;*.jpeg;*.bmp")]);
}
private function imgLoad(e:Event):void
{
fr.load();
}
private function imgExtract(e:Event):void
{
var img_br:ByteArray = new ByteArray();
img_br = fr.data as ByteArray;
var loader:Loader = new Loader();
loader.addEventListener(Event.COMPLETE,imgDisplay);
loader.addEventListener(IOErrorEvent.IO_ERROR,imgLoading);
loader.loadBytes(img_br);
pathtxt.text = "Loading "+img_br.length+" : "+loader;
}
private function imgLoading(e:IOErrorEvent):void
{
pathtxt.text = "here";
//imgProgress.setProgress(e.bytesLoaded,e.bytesTotal);
}
private function imgDisplay(e:Event):void
{
image = e.currentTarget.loader.content as Bitmap;
imgPreview.addChild(image);
pathtxt.text = fr.name;
}
When I run the above, it doesn't seem to trigger the imgDisplay or imgLoading functions(imgLoading was supposed to be progress event, but I changed it for testing).....it seems, the eventListeners are not working, any idea?