Jump to content
Search Community

How to get the "scaled" image size with the scaleMode:"prop?

stephan test
Moderator Tag

Recommended Posts

Hi,

how can I get the "scaled" size of the content(image), if I have the scaleMode:"proportionalInside" property?

I get the "real" size of the loader via: picLoader.content.width, but to show the entire pic(depending on the screenSize) I have the scaleMode.

Works fine but for positioning the close Button and some description text in a kind of "lightbox" I need the scaledImageSize...

Hope there`s a way to solve my problem...

Thanks.

Link to comment
Share on other sites

thanks carl, but that doesn`t work...

I grouped every loader now in the LoaderMax, get the width and height now via "LoaderMax.getContent("pic_1").width" and "LoaderMax.getContent("pic_1").height",

but that`s not the correct size of the images with scaleMode:"proportionalInside"... :roll:

If I try "LoaderMax.getLoader("pic_1").rawContent" I get "undefined..."

Link to comment
Share on other sites

AAAAARRRRRGGGGHHHHH!!!! :oops:

For all who struggle in the same problem:

Getting the real size of the scaled image works (of course) fine with "LoaderMax.getLoader("pic_1").rawContent.width", but needless to say AFTER loading...means in the onComplete Handler

Thanks carl :)

Link to comment
Share on other sites

lol. you just had me double-checking a test I made last night.

 

yeah, you need to do it after onComplete.

 

the following code

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.easing.*;


import com.greensock.events.LoaderEvent;
import flash.display.Loader;


var carIL:ImageLoader = new ImageLoader("car.jpg", {container:holder, width:100, height:300, scaleMode:"proportionalInside", onComplete:loaded});

loadScaled_btn.addEventListener(MouseEvent.CLICK, test);

function loaded(e:LoaderEvent):void{
trace(carIL.content.width);
trace(carIL.rawContent.width)
}


function test(e:MouseEvent):void{
carIL.load();
}

 

will load a big image 300 x 200 into the 100 x 500 container and

the loaders content and rawContent will both be 100 (the scaled size)

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...