A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Image loading problem

Threaded View

  1. #1
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766

    [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?
    Last edited by bluemagica; 10-11-2009 at 12:30 AM. Reason: Topic solved by myself. Solution: forgot to use contentLoaderInfo
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center