Share Posted August 18, 2009 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 More sharing options...
Share Posted August 18, 2009 I'd recommend simply storing the transform.matrix values instead of scaleX/scaleY/width/height/rotation. It's cleaner that way. If you must store the width/height, you could use textField.getBounds(textField). Link to comment Share on other sites More sharing options...
Author Share Posted August 18, 2009 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 More sharing options...
Author Share Posted August 18, 2009 BTW, I just tried the getBounds method and it works well for the width and height, though I would still like to explore storing the transform.matrix values. Link to comment Share on other sites More sharing options...
Share Posted August 18, 2009 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 More sharing options...
Author Share Posted August 18, 2009 Great, Thank you very much, that makes sense. Regards 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