arobertson Posted June 19, 2017 Share Posted June 19, 2017 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 More sharing options...
Carl Posted June 20, 2017 Share Posted June 20, 2017 This should help: 1 Link to comment Share on other sites More sharing options...
arobertson Posted June 20, 2017 Author Share Posted June 20, 2017 Carl - superb! You're the man. Thanks for the quick response and reference. Always a pleasure. 1 Link to comment Share on other sites More sharing options...
arobertson Posted June 20, 2017 Author Share Posted June 20, 2017 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 More sharing options...
arobertson Posted June 20, 2017 Author Share Posted June 20, 2017 Well, I think i answered my on problem. Was it because I had the incorrect scaleMode set (proportionalInside vs proportionalOutside)?? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now