PDA

View Full Version : upload image - detect size


johnkainn
08-20-2008, 05:47 PM
I upload and display an image in a movieClip, by using filereference class.
If I try to get the height of the movieClip that the image is loaded into, I only get the height before the image was loaded in.
I tried to get the size in CompleteF.
fileReference.addEventListener(Event.COMPLETE, completeF);
and also

var pict:Loader=new Loader();
var url:URLRequest=new URLRequest();
...
myMovie.addChild(pict);

If I place a button on stage and click it after the image has been loaded I get the correct size. I would however like to get the size without clicking a button. How can I do that? I appreciate your help.
Thanks

mfalomir
08-20-2008, 06:50 PM
Im not sure if I got what you meant, however if you want to know the dimensions of the image once is loaded you just add and event listener to your Loader object :

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, onLoaded);

function onLoaded(e:Event):void
{
trace( loader.content.height); // e.target.height is the same
trace( loader.content.width); // e.target.width is the same
}

is that what you mean ?
:)

johnkainn
08-20-2008, 07:07 PM
This is exactly what I meant. Thank you very much for your help:-)

mfalomir
08-20-2008, 07:12 PM
:) Cool