
Page 2 of 4
First off flash uses radians to measure angles not degrees, more on this next. For now degrees.
The maximum rotation around any Cartesian coordinate system is 360 degrees. In Flash if you are moving clock wise this will be a positive number in degrees until you reach 180 degrees. If your are moving counter clock wise this will be a negative number until you reach 180 degrees. Remember all rotation in flash starts from 0 degrees. Your options are either moving clock wise or counter clock wise. If you want to move counter then you need a negative number. If you want to move clock wise you need a positive number. I know this might be a stretch but if you think about 45 degrees is also the same as -315 degrees. It just all depends on which direction around the clock you are moving and your purpose for rotating around a circle.
Now using the _rotation property of a movie clip will return a value between 0 degrees and 180 degrees or if you are moving counter clock wise a value between 0 degrees and -180 degrees. Take a look at the swf. I know this may be a little confusing. Just remember that if you use the movie property _rotation that if you want to move counter clock wise use a negative number and if you want to move clock wise use a positive number.
When getting the angle value for a movie clip on the stage remember that you could get a negative number. This is shown by dragging the movie clip around the stage in the swf. below. The value returned and used by the _rotation property is in degrees. This gets complicated because flash math functions return values of an angle in radians (Which is an angle in terms of the constant pi or 3.14 ). Radians are good for math but not so good when you want to alter the _rotation property of a movie clip If you are not using the _rotation property then be prepared to get a handle on radians.
![]() |
Drag the orange circle with the mouse |
Action script from swf
onClipEvent (mouseDown) {
startDrag (this, true, 0, 0, 150, 150);
}
onClipEvent (mouseUp) {
stopDrag ();
}
onClipEvent (enterFrame) {
Radians = Math.atan2((this._y-_root.center._y), (this._x-_root.center._x));
this.degreetextbox = Math.round(Radians*180/Math.PI)+" degrees";
}
Use this equation when you want to change radians to degrees. Flash usually returns the value of an angle in radians when using a math function.
Degrees=Math.round(your_angle*180/Math.PI)
Remember, your angle is in Radians before you convert it.
READ THIS: The swf below shows what the out put would be if you did not convert from radians to degrees.
onClipEvent (mouseDown) {
startDrag (this, true, 0, 0, 150, 150);
}
onClipEvent (mouseUp) {
stopDrag ();
}
onClipEvent (enterFrame) {
radians = Math.atan2((this._y-_root.center._y), (this._x-_root.center._x));
this.radiantextbox = radians;
}
The distance between any two points is defined by the following equation:
c = square root (a*a + b*b)
<img width="471" height="312" border="1" src=" =""/>
| Drag clip a with the mouse notice that both clip a and b give the distance from each other which is of course always the same. However it might come in handy to have two thinking movie clips that both now how far they are from each other. |
onClipEvent (load) {
var y1 = 0;
var y2 = 0;
var x1 = 0;
var x2 = 0;
}
onClipEvent (mouseDown) {
startDrag (this, true, 0, 0, 150, 150);
}
onClipEvent (enterFrame) {
y1 = _root.aclip._y;
x1 = _root.aclip._x;
y2 = _root.bclip._y;
x2 = _root.bclip._x;
x_cord = x2-x1;
y_cord = y2-y1;
_root.aclip.distance_from_bclip = Math.round(Math.sqrt(x_cord*x_cord+y_cord*y_cord));
}
onClipEvent (mouseUp) {
stopDrag ();
}
onClipEvent (load) {
var y1 = 0;
var y2 = 0;
var x1 = 0;
var x2 = 0;
}
onClipEvent (enterFrame) {
y1 = _root.aclip._y;
x1 = _root.aclip._x;
y2 = _root.bclip._y;
x2 = _root.bclip._x;
x_cord = x2-x1;
y_cord = y2-y1;
_root.bclip.distance_from_aclip = Math.round(Math.sqrt(x_cord*x_cord+y_cord*y_cord));
}


