Aspin
Aspin

Reputation: 1

Download an image and get its size - doesn't work with big sized images?

The image is huge, the code does not work as intended - what is the problem with this code?

package {
    import flash.display.*;
    import flash.events.*
    import flash.net.*;

    public class something extends Sprite {
        public function something():void {
            var loader:Loader = new Loader();
            loader.load(new URLRequest('http://www.decidio.com/photos_company/small/83336.jpg'));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
                trace(e.currentTarget.content.width);
            });
        }
    }
}

Upvotes: 0

Views: 265

Answers (1)

www0z0k
www0z0k

Reputation: 4434

check if it fires Event.INIT and check bytestotal and bytesloaded on progress to see where's the problem. also for big amounts of data i'd recommend to use URLStream class

upd: maybe it'd be better to add listeners before you start loading and to check typeof(e.target)

Upvotes: 2

Related Questions