11 Replies Latest reply on Dec 16, 2009 10:26 PM by Rothrock

# Width/Height of a rotated clip

Say I've got a box that is 218 by 86. If I rotate it to 50 degrees then the width and height are reported as 206 by 222.3.

I'm trying to take those rotated values back to the original values and I'm having a bad math day and can't figure it out.

Anybody?

• ###### 1. Re: Width/Height of a rotated clip

to get those original values you must know the rotation.  if you know the rotation, reverse it, obtain the width/height then rotate back and proceed.

1 person found this helpful
• ###### 2. Re: Width/Height of a rotated clip

Thanks. I had kind of figured that out. But it wasn't working so then I thought I might need some fancy trig, but I couldn't figure it out.

However it turns out to be more complex that I had thought.

I'm creating an outline/highlight component that will draw a box around stuff on the screen.

I've got it all working pretty well, but the live preview of the component is what is all messed up.

I put a horizontal rectangle shaped component on the stage and the preview shows the outline where I would expect.

Now I rotate it 90 degrees. The width is now the height and vice versa. So the bounding box is now a tall vertical rectangle, but the live preview still shows a horizontal rectangle. But when I publish it correctly fits to the bounding box!

So I went exploring and found that the live preview has no _rotation property--or more precisely it is always 0.

So now I'm really confused. Any thoughts?

• ###### 3. Re: Width/Height of a rotated clip

I am able to get the transform.concatenatedMatrix when I rotate the clip but I'm not sure if it is acurate....

• ###### 4. Re: Width/Height of a rotated clip

I'm confused by the concatenatedMatrix.

It is showing an a value of 1.41937255859375 when it is dropped on the stage. Which I would expect to be 1 since there is a rotation of zero.

Then if I rotate to say, 45 I get an a value of 1.00364685058594, when I would expect .70710754.....

• ###### 5. Re: Width/Height of a rotated clip

Okay figured that out. The value was (more or less) the amount I had the authoring environment stage scaled by.

Because the live preview all runs in an instance of the player which is on the stage, the transform matrix has to reflect that to show zoomed in/out.

Of course I still don't know how to back up to the size that the thing should be, but I'm making some progress....

• ###### 6. Re: Width/Height of a rotated clip

i don't know what you're doing but i do know the concatenatedMatrix is pixel perfect when i use it to calculate bitmaps of nested transformed movieclips in a shape-based hittest i developed.

• ###### 7. Re: Width/Height of a rotated clip

I think I'm understanding the concatenatedMatrix now. It is working off the stage window in the authoring environment.

The screen shot below shows how the outline is drawing when previewed on the stage. It should be inside the bounding box. And when I publish it is inisde the bounding box. So there is something that they left out of their live previewing. I'm trying to figure out a way to fake the data.

So given the rotated width and height, and the concatenated Matrix, is there a way that I can use its values to reconstruct the actual width and height of my clip?

• ###### 8. Re: Width/Height of a rotated clip

i started to look at this and quickly ran into a flash bug:  the concatenatedMatrix of the _root timeline is a function of the stage dimensions!.

• ###### 9. Re: Width/Height of a rotated clip

And the problem with that is? I'm not getting the concatenatedMatrix of the root timeline. I'm getting it from my component.

So for example when I put the component on the stage it is:

(a=1.4199982881546, b=0, c=0, d=1.4199982881546, tx=494, ty=246)

The 1.4199... corresponds to a zoom of 142 of the preview of my stage.

Then if I rotate the component to 45 degrees I will get a concatenated matrix of something like:

(a=1.00408935546875, b=1.00408935546875, c=-1.00408935546875, d=1.00408935546875, tx=494, ty=246)

So is there any way I can use the new matrix to realize that the component is rotated 45 degrees?

I know that if there is no scaling I can just do something like:

Math.acos(this.transform.concatenatedMatrix.a)*180/Math.PI

And that will tell me the rotation of the clip. But with the scaling mixed in I'm not sure how to extract the rotation.

It seems when there are components with live preview there is a _level0.contents container that holds all of them. So perhaps I can get the concatenatedMatrix of the contents clip and use it to get the scale and then I can reduce the values in the component's concatenated matrix by that percentage and then get rotation.

Of course I'm at home now, so I'll have to wait until tomorrow to figure this out...

• ###### 10. Re: Width/Height of a rotated clip

the problem is that if the root timeline's concatenatedMatrix (cm) is incorrect, all cm's are incorrect.  and whether the root timeline's cm's may or may not be correct depends on your stage size.

anyway, given a zoom and the cm, you can find the rotation using:

_rotation = Math.asin(zoom/cm.a)

1 person found this helpful
• ###### 11. Re: Width/Height of a rotated clip

Thanks. I guess I'm just going to have to live without rotating the border - or at least one that looks like it is supposed to!

I just noticed that the same happens if I rotate an accordion component, scrollpane, etc.