Jump to content
Search Community

TextField width and height after rotation

cugreen test
Moderator Tag

Recommended Posts

Hi Greensock,

 

I have a problem getting the width and height of my TextField. Basically what I am trying to do is get the user interaction of the TransformManager and send the details back to a database, then get the database back and re-apply it to the TransformManager. Ofcourse there is no problem using display objects, but, when I use a TextField it's different story. You may be able to suggest a better way to do it.

 

Basically, I am listening for the events from the TransformItem (SCALE, MOVE, ROTATE) then updating an object on those events, then when the user saves, the object is sent off to the database. With the display objects size, I am storing the scaleX and scaleY, that works fine, but because the scaleX and scaleY for the TextField is always 1, I am storing the width and height, when the TransformItem is rotated, it returns the TransformItems height and width when I try to get the TextFields height and width.

 

Any ideas?

Link to comment
Share on other sites

Thankyou for a quick response.

 

I'd recommend simply storing the transform.matrix values instead of scaleX/scaleY/width/height/rotation. It's cleaner that way.

 

That's good to know. I tried using the MatrixTools to get the scaleX and scaleY, is that what you mean? sorry, I'm not too familiar with transform.matrix or how to get the values back into TransformManager, do you have a small example?

 

Thanks again

Link to comment
Share on other sites

I tried using the MatrixTools to get the scaleX and scaleY, is that what you mean? sorry, I'm not too familiar with transform.matrix or how to get the values back into TransformManager, do you have a small example?

 

Nope, I just meant you should store the Matrix values themselves. Those control all the aspects of the scaleX/scaleY/width/height/rotation/x/y anyway. Like:

 

var matrix:Matrix = myObject.transform.matrix;
//store these values...
var a:Number = matrix.a;
var b:Number = matrix.b;
var c:Number = matrix.c;
var d:Number = matrix.d;
var tx:Number = matrix.tx;
var ty:Number = matrix.ty;

//then later, to re-apply them...
myObject.transform.matrix = new Matrix(a, b, c, d, tx, ty);

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