Jump to content
Search Community

Transform ContentDisplay Width / Height instead of Scale

Sam test
Moderator Tag

Recommended Posts

I am trying to use the TransformManager in combonation with the LoaderMax ContentDisplay. In my application I expose the ContentDisplay scaleMode options to the user (ProportionalInside, ProportionalOutside, and Stretch).


Attaching the TransformManager to the ContentDisplay works just fine for rotation and position but it is misleading for scale. The TransformManager scale warps the ContentDisplay. When the ContentDisplay scaleMode is set to Stretch this makes perfect sense but when the ContentDisplays scaleMode is set to either of the Proportional settings it seems like it should change the bounding box width instead. That way the image continues to fill maintain proportion according to the scaleMode.


I attempted the TransformManagers constrainScale and this guarantees that the original fitHeight and fitWidth aspect ratio are maintained which helps in the cases where the scaleMode is set to proportional but sacrifices the ability to change the shape of the bounding box.


I guess that is my question: Is there a way to make the TransformManager change the ContentDisplay bounding box?


Thoughts, feelings, assistance?

Link to comment
Share on other sites

RTFM. For the next slow poke...


transformItem.scaleMode = TransformManager.SCALE_WIDTH_AND_HEIGHT


now to get the ContentDisplay object to update as it is being scaled...

Link to comment
Share on other sites

Ha ha. No problem. Glad you figured that out. But I'm still not sure you'll get the scaling behavior you want with that solution. Let me explain...


ContentDisplay is purposely built so that it's relatively lightweight and functions just like a regular Sprite except that it adds a few properties and features (like fitWidth/fitHeight). The behavior you're describing is much more complex because it would require looking at the transform.matrix and counteracting what's applied in order to maintain certain proportions. For example, if you change the scaleX to 0.5, it would need to change the target's scaleX to 2 and then run logic to fit it into the area so that outside of that object, it still appears to still have a scaleX of 1.


The behavior you described (if I understood it correctly) is exactly what AutoFitArea does (com.greensock.layout.AutoFitArea). I'd recommend giving that a shot instead of relying on ContentDisplay. Technically ContentDisplay could do what you're asking as long as you set the fitWidth and fitHeight INSTEAD of altering its transform.matrix or width/height/scaleX/scaleY. However, TransformManager alters the transform.matrix (or width/height if you set that scaleMode). I suppose you could use a proxy of sorts where you create a transparent Sprite on top of your object and listen for TransformManager events on the associated TransformItem and apply the changes to the ContentDisplay's fitWidth/fitHeight properties. Or listen for those events and analyze the transform.matrix and figure out what the fitWidth/fitHeight should be and make the changes necessary, but I suspect that it'd be easier for you to just use AutoFitArea.


But if setting the transformItem's scaleMode to SCALE_WIDTH_AND_HEIGHT gets what you want, great. :)

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