PDA

View Full Version : Getting the width of a picture.


jhaddington
11-14-2008, 04:49 PM
Hi Guys,

This maybe a really simple question but I seem to be having a problem with getting the width of a picture I am loading. Obviously the height and width of the logo isn't 0 however when doing a trace on logo.width is it coming back 0. Is it something I am doing wrong!? My code is below.

Cheers
:)

var logoPicture:Loader = new Loader();
logoPicture.load(new URLRequest("http://www.saferonline.maybovrm.com/images/logos/"+logo));
addChild(logoPicture);
trace(logoPicture.width);
trace(logoPicture.height);
//logoPicture.x = (centerPoint.x - logoWidth);
logoPicture.y = centerPoint.y - (logoPicture.height*0.5);

runtime
11-14-2008, 05:06 PM
Yes, you need to use contentLoaderInfo.
You also need to put an event listener on your load and run an init function.

There are several posts regarding this.

Here is one that should help you:
http://www.actionscript.org/forums/showthread.php3?t=139092

Good luck and if you need more help just ask.