.width reporting 0

So if I :

var papa1: Loader = new Loader();
papa1.load(new URLRequest(“img/img.png”));
trace (papa1.width);

Comes out as zero… I thought I had used this before but now it comes back as zero.
What am I missing here, did something change with .width or I just think it used to work printing out the width ?

Loader is asynchron, you need to listen on the “complete” event. (Details)

Why not:

var papa1:Bitmap = new Bitmap (Assets.getBitmapData ("/img/img.png"));

Thanks, I keep forgetting about this.

You can also use:

Assets.loadBitmapData ("img/img.png").onComplete (function (bitmapData) {


BitmapData.loadFromFile ("img/img.png").onComplete (function (bitmapData) {
1 Like

Thanks, I think this is some weird mental block with async on my part.