Jump to content
Search Community

Loader return image's original width and height

bluebill1049 test
Moderator Tag

Recommended Posts

Hi there,

 

var stageProductImageLoader:ImageLoader = new ImageLoader(_IMGDIR + e.target.parent.parent.productCategory + '/' + e.target.parent.parent.productId + ".png",

{container: _allTempleProducts[0].mc_stageProductContainer,

height:80,

x:-15,

y:0,

hAlign: 'left',

vLaign: 'top',

scaleMode: 'proportionalInside',

centerRegistration: false

});

 

is there i way i can get the image's original width and height, cause i want to know the ratio of the image.

 

Thanks

Bill

Link to comment
Share on other sites

what you can get is the scale of the rawContent of the loader. using that you can determine the original width

 

in your case:

 

trace(stageProductImageLoader.rawContent.width/stageProductImageLoader.rawContent.scaleX) // output original width

Link to comment
Share on other sites

var stageProductImageLoader:ImageLoader = new ImageLoader(_IMGDIR + e.target.parent.parent.productCategory + '/' + e.target.parent.parent.productId + ".png",

{container: _allTempleProducts[0].mc_stageProductContainer,

height:80,

x:-15,

y:0,

onComplete:onImageLoad,

hAlign: 'left',

vLaign: 'top',

scaleMode: 'proportionalInside',

centerRegistration: false

});

 

private function onImageLoad(e:LoaderEvent):void{

//trace(e.target.rawContent.width/e.target.rawContent.scaleX)

trace(e.target.rawContent.width/e.target.rawContent.scaleX);

}

 

i had this but it doesn't return me the right width, anything wrong i did?

 

Cheers

Bill

Link to comment
Share on other sites

nothing jumps out at me. I tried to break my own example many times with different images and always got the proper result.

 

good news is this should work fine:

 

trace(e.target.rawContent.bitmapData.width);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...