Jump to content
Search Community

Scale rectangle

danut test
Moderator Tag

Recommended Posts



I am trying to scale a rectangle, based on it's initial transformation matrix and on it's final one. The scaling phase is done using the scaleSelection() function from the TransformManager.as file.

It is working fine for all cases, except the one when the rectangle is initially rotated, and only after that the scaling applies.

Here are my input data:


initial transformation matrix:

a = 0.85

b = -0.51

c = 0.51

d = 0.85

tx = 75

ty = 124.05

width = 140

height = 116


final transformation matrix (after the rectangle is scaled):

a = 1.48

b = 0.88

c = 0.90

d = 1.52

tx = 196.45

ty = 113

width = 243

height = 203


The modified scaleSelection() function looks like this:


//I added two more parameters (the initial matrix- initialMatrix and the final matrix- sMatrix)

//After the scaling phase I added a translation to place the rectangle in the right position. This is not working when the rectangle is rotated before

public function scaleSelection($sx:Number, $sy:Number, $dispatchEvents:Boolean = true, sMatrix:Object = null, initialMatrix:Object = null) {


//same as before


var tx:Number = sMatrix.matrix.tx - (sMatrix.width - initialMatrix.width)/2;

var ty:Number = sMatrix.matrix.ty - (sMatrix.height - initialMatrix.height)/2;

moveSelection(sMatrix.matrix.tx - tx, sMatrix.matrix.ty - ty);




I belive that the tx and ty are not properly computed. I don't know where to add the rotation angle for the tx and ty computation.





Link to comment
Share on other sites

I'm having a hard time understanding the issue - could you post a very simple FLA that demonstrates the issue? Please don't post your production files or the TransformManager classes; just a very simple FLA with the necessary code to show what's going on. That would be super helpful in terms of understanding the question and identifying the issue. Feel free to PM me if you don't want to post it here.

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