Jump to content
Search Community

Question on Transform Matrix object width/height

gparker test
Moderator Tag

Recommended Posts

OK, I have been reviewing the export/apply item XML that's included with TransformManager. At first I didn't understand why you needed the Transform Matrix, but given that you can rotate two images different ways, group them, then resize them (non proportional) it's easy to see how they quickly turn into non-rectangular shapes.

 

However, my application won't use crazy skewing like that, it will always have the constrainScale = true on. Given that, I'm wondering if it's possible to just export the movie clip's x, y, width, height, and rotation?

 

I've noticed that while tracing the object that TransformManager is transforming, I can see changes to the x, y, and rotation by default. However, the width/height doesn't change, nor does the scaleX or scaleY, so I'm thinking that the sizing is handled by the matrix. However I'm not familiar with working with the transform matrix. Is there an easy way to remove that transform matrix when it's done scaling so I can get the new width and height?

 

I ask because I need these values and we already have a complicated export/import XML schema set up in my application, and I don't have time or the project requirements to add in your more complex positioning XML. I just need to get the new width and height of an object when it's done transforming, so yeah... let me know if that's possible, thanks!

 

edit: I've also tried this:

manager.addItem(myDisplayObject, "scaleWidthAndHeight");

which will return the width and height, but then it doesn't scale any children of the object. So, I guess I'm wondering if there is a way to do it where the "scaleNormal" behavior is on, except at the end of the transform, set the width and height to the object?

Link to comment
Share on other sites

You must be using this in Flex, right? Flex is notorious for incorrectly reporting values like width and height (which has nothing to do with TransformManager by the way).

 

Just so you know, the matrix isn't really some fancy add-on feature thing with DisplayObjects - you can actually think of it as more foundational than width/height/scaleX/scaleY/rotation/x/y because all those values are essentially derived from the matrix behind the scenes. If you want to understand the matrix better, there's a great article by Senocular at http://www.senocular.com/flash/tutorials/transformmatrix/

 

Anyway, it sounds like you're trying to transform an object that has non-standard behavior and is applying custom sizing logic. You should definitely be seeing the scaleX/scaleY changing when you're scaling with TransformManager (unless you're using the SCALE_WIDTH_AND_HEIGHT mode in which case you should see those changing - either width/height or scaleX/scaleY or both but never neither). Feel free to post a sample project that demonstrates the issue (although please don't include the TransformManager classes). No need to post your production files - just something very basic. Don't forget to zip it first.

Link to comment
Share on other sites

You must be using this in Flex, right?

 

Yes, I am using Flex for this application. However, I'm opting not to use the FlexTransformManager, since all of my application display objects I'm manipulating are created programmatically through actionscript, not mxml. I will admit that I didn't investigate the FlexTransformManager very much since the standard one seemed to work fine right off the bat, but if you believe I should be using that instead let me know.

 

The application is pretty large and I'm using DeMonster Debugger for the traces, but I'll see if I can't isolate a part of the code that's doing this and make an example (excluding your class). It may be something else Flex related like I need to run a invalidateDisplayList(); or something when it changes... Thanks for the feedback, I'll work on this a bit more and post back in a bit.

Link to comment
Share on other sites

SUCCESS! I was able to get the updated width and scale of the objects doing this:

 

add them to the manager like so (any of the TransformEvents seem to work, here I'm just using the SELECT_MOUSE_UP but will probably change it to something more robust later):

var tmItem:TransformItem = manager.addItem(region);
        tmItem.addEventListener(TransformEvent.SELECT_MOUSE_UP, tmOnMouseUp);

private function tmOnMouseUp(event:TransformEvent):void {
           var tmItem:TransformItem = event.target as TransformItem;
           MonsterDebugger.trace(this, "function tmOnRelease width:"+tmItem.width);
           MonsterDebugger.trace(this, "function tmOnRelease scaleX:"+tmItem.scaleX);
       }

 

that returns both values, so I can use that to get them to update it elsewhere in the application where Flex is being stubborn and not updating it. Although, I will probably have to set the scaleX to 1 if I manually update the width on the object container, so I may just update the data model for the object's export info. Hope this may help if someone runs into something similar.

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