I’ve the following code that loads a list of thumbnail jpgs - I need to get the width of each loaded item so as to centre them vertically within another object but I can’t get the image attributes until the image is loaded.
I’ve added a COMPLETE listener - which traces the widths fine - am I right in thinking that I can’t use a ‘return’ within an event listener?
If not, how can I get to the various jpg widths in order to use them?
Many thanks in advance,
Pt
function ImageLoad(u:String,Ypos,Xpos){
var positionY = Ypos;
var positionX = Xpos;
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(u);
loader.load(request);
loader.name = u;
scrollBox1.content.scaleX=1;
scrollBox1.content.addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
}
function loaded(event:Event):void {
trace(event.target.loader.contentLoaderInfo.width);
// the above line traces the widths fine - but how do I pass these back to the original ImageLoad function to use the values?
}