Jump to content
Search Community

GSAP Scale

arobertson test
Moderator Tag

Recommended Posts

Good day to all, I have searched through the documents but am not able to easily find my answer so I am hoping this is a quick response for the professionals. Is there an easy way to find out the scale ratio of the image that is imported at run time?

loader = new ImageLoader(theURL+"SEN"+viewNum+".jpeg", {name:"SuperEnhanced_View3", estimatedBytes:3000, container:xrayLoader, x:408, y:384, width:820, height:768, scaleMode:"proportionalInside", centerRegistration:true, alpha:0, onInit:onImageLoad, onError:errorHandlerMain});

 

Reason: I am trying to place an overlay over the image in the correct location but when the image is scaled, the object needs to be modified accordingly.

 

Thanks,

Andrew

Link to comment
Share on other sites

Well since that worked, I have now been spun into another issue that I just can't jump over.

 

When I attempt to get the scale from the code below, it provides me with the scaleX 1.6 and scaleY 1.6 which is fine and dandy, but once I apply this scale ratio to my drawings they are off.

 

For example, original file is 486/480 and when it resizes it bumps up to 768/777.6 which, if I use my calculator, provides me with a X scale ratio of 1.580247 and Y scale ratio of 1.62 and not the ratios provided above.

 

Below is my code:

 

	//Go and fetch the native width/height of the image.
	var rawContent:DisplayObject = imageGSAP.rawContent;
	var bounds:Rectangle = rawContent.getBounds(rawContent);

	trace(event.target + " for image " + imageCount + " is complete!");
	trace(event.target + " original width is " + bounds.width + " with a height of " + bounds.height);
	trace(event.target + " current width is:" + rawContent.width + " with a height of " + rawContent.height);
	trace(event.target + " current scale is X:" + rawContent.scaleX + " and scale Y:" + rawContent.scaleY);

 

bounds.width = 486

bounds.height = 480

rawContent.width = 768

rawContent.height = 777.6

rawContent.scaleX = 1.6

rawContent.scaleY = 1.6

 

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