Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-24-2009, 01:35 AM   #1
Renderer10
Registered CS5 User
 
Join Date: Nov 2009
Location: Somewhere in the USA
Posts: 196
Default Global Scaling?

Ok, I've been struggling with a problem for about a week now, and finally decided to create an account here; hopefully I can provide as much help to others as I receive!

The problem: I need to be able to scale a rotated instance globally, not along the local x and y axis of the instance.

I realize that there is no such thing as "rotation", but that scaling and skewing are used to make an instance appear rotated. I haven't tried messing with the instance's transformation matrix yet, I really don't think that would help right now. I've been trying to use trig to scale locally and have it appear global, but no luck with that either. Nested movieclips won't work, simply because it would wreck havoc with any other transformations.

Any help with this is greatly appreciated, if anything sounds a bit vague, just ask to have it clarified!

-Renderer10
Renderer10 is offline   Reply With Quote
Old 11-24-2009, 07:44 AM   #2
chups
Registered User
 
Join Date: Oct 2009
Posts: 35
Default

Put each instance inside it's own separate container sprite, then scale instances (not containers) and rotate containers (not instances).
chups is offline   Reply With Quote
Old 11-24-2009, 05:24 PM   #3
Renderer10
Registered CS5 User
 
Join Date: Nov 2009
Location: Somewhere in the USA
Posts: 196
Default

Thanks, but that won't cut it. I actually need to be able to scale an object along any angle, taking into account any previous scaling. I already have a system set up that takes care of the previous scaling, but how would I go about scaling along any angle? Anyone have a way to approach this with trig? I've been trying and trying... to no avail
Renderer10 is offline   Reply With Quote
Old 11-24-2009, 09:38 PM   #4
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default

Chups is right though, have a movieclip to perform scaling on and inside it another to rotate (or vice versa)
'Taking into account any previous scaling' sounds like incrementing scaling, which is a matter of performing a correct calculation, the rotating (or not) of it's children doesn't make any difference.
Still, if you're quite certain this isn't what you want to do you'll need to explain it more visually I guess...
creynders is offline   Reply With Quote
Old 11-24-2009, 09:52 PM   #5
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

So when you say global scale you mean you want to scale against a center point other than the object's local 0,0?
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 11-24-2009, 11:33 PM   #6
Renderer10
Registered CS5 User
 
Join Date: Nov 2009
Location: Somewhere in the USA
Posts: 196
Default

@abeall, yes, but I've already taken care of that, by global, I mean no matter how the object is rotated, I want to be able to scale it along the stage's x and y axis, not the object's.

To everyone else:

Ok, well I'm working at developing an actual application, and I need to have an interface that provides intuitive controls for common transformations like dragging, rotating, and scaling. I have the scaling left to complete yet, before I can move on with this application. I've attached a swf of the last stable compilation, that is before I started with the scaling concept. You'll be able to see what I'm aiming for by checking this out (please note, I have made a few updates to fix minor issues in this, but that release isn't stable yet).

I want the user to be able to simply select objects, and have to ability to transform them however they want with no restrictions. So no matter what the rotation(actually scale and skew) or scale was before hand, I want them to be able to scale the object(s) in the direction desired.

So yes, the rotation of the children(if I would use that method) does matter. If you scale the parent instance, then rotate the child instance, it will constantly be distorted by the scaling of the parent instance.

Try this: Open Flash, draw a shape, and make it a symbol. Then scale that symbol along the x axis. Now double click that symbol and rotate the contents - you'll see how they are being affected by the scale. However, if you scale the symbol, then rotate the symbol(instead of rotating the contents), you'll see that the scale is preserved as the object is rotated. That's what I need to accomplish, hopefully that explanation helped.

I've been playing with the transformation matrix, and that allows you to scale an object globally, since your essentially bypassing the rotation. There is no rotation with the transform matrix, the rotation is stored directly as scale and skew information, meaning I can alter the scale on a global axis (scaleX and scaleY aren't pulled from the matrix, but are rather calculated by reverse-engineering the matrix info and using trig to make them "local", hence why I can't use them). However, with the matrix method, now the skew becomes a problem. When changing the scale on a "rotated" object, the skew stays the same, thus distorting the object. Does any of this make sense?

I've been working on the skew problem, but I haven't even come close to fixing it. The skew data in the transformation matrix is stored as the tangent of the skew angle(in radians). I've successfully extracted it with arctan, but I'm not sure what to do with the data...

I know this is rather complicated, but I haven't found ANY relevant information about the math involved in doing this, other than how matrices are used and how trig works(which I already understand). I was really hoping someone here could help... Thanks in advance!

For those interested in the attached file:

The only object you can add are the pentagons you see, however you can change the color using the text input. Click objects to select, hold shift or ctrl to select multiple objects. You can also drag a selection box, and if you hold shift when you let go, the objects will be added to the selection. Shift-clicking an object will also deselect.
Dragging objects is self-explanatory, though if you hold shift while dragging, you can snap the drag in 45 degree increments. Your selection will also snap to other objects while dragging, and you can also snap the selection back to it's original position by moving your mouse close to the "+" that appears. You can also use the arrow keys to "nudge" selected objects.
To rotate objects, turn on the transform handles (middle button), and hover your cursor outside the corner handles(just like in flash) to get a spin cursor, then click to rotate. It will automatically snap in 90 degree increments relative to the starting rotation, but if you hold shift, it will give you even more precision. You can drag the little white circle to change where the object(s) rotate around, and the circle will snap to each grab handle, as well as to the center of the transform box.
Right-clicking objects gives you depth controls, and you can even re-order multiple objects while preserving their order.
Auto-snapping can be toggled with the magnet button, though even with it off, shift-snapping still works.

Questions/comments/suggestions on the project so far are also welcomed!

-Renderer10

Last edited by Renderer10; 11-27-2009 at 04:53 PM.
Renderer10 is offline   Reply With Quote
Old 11-25-2009, 02:55 AM   #7
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

Have you seen these?
http://www.senocular.com/?entry=372
http://www.senocular.com/flash/tutor...ansformmatrix/
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 11-25-2009, 03:07 AM   #8
Renderer10
Registered CS5 User
 
Join Date: Nov 2009
Location: Somewhere in the USA
Posts: 196
Default

I've seen the second link, but not the first... I'll have to check it out. I want to use my code, as I'll have a full understanding of how it works, but I may be able to learn a thing or two from it though! Thanks a lot, though I'm still open to others ideas.

-Renderer10
Renderer10 is offline   Reply With Quote
Old 11-25-2009, 07:13 AM   #9
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default

Quote:
Try this: Open Flash, draw a shape, and make it a symbol. Then scale that symbol along the x axis. Now double click that symbol and rotate the contents - you'll see how they are being affected by the scale. However, if you scale the symbol, then rotate the symbol(instead of rotating the contents), you'll see that the scale is preserved as the object is rotated. That's what I need to accomplish, hopefully that explanation helped.
That's exactly what you get if you have separate movieclips to perform the separate transformations on: 1 for scaling, 1 for rotation. However, you have to scale the inner movieclip, not the outer one. (In other words, have a movieclip for rotating and inside it one for scaling)
To try it out create a shape, place it in a movieclip 'a' and place that in a movieclip 'b'
then add this code to the timeline:
ActionScript Code:
b.a.scaleX = 1.5; b.rotation = 125
You'll notice that it's scaled and rotated, but not skewed like it would be if you would scale 'b' and rotate 'a'
creynders is offline   Reply With Quote
Old 11-25-2009, 07:52 AM   #10
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

Something else that comes to mind, if you aren't implementing skewing in the first place you don't have to build the transform tool around the transform matrix. DisplayObject's rotation property would make it very easy to maintain the relative transform which it seems like you are describing, but to me that's the opposite of "global" scale so I'm still not sure I understand.
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:04 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.