i want to rotate square around x axis. this is the code for rotating 1 point(draw a circle or something like that and copy code):
var centar:Object = new Object();
centar.x = 250;
centar.y = 250;
var angle:Number = 0;
var radius:Number = 50;
var speed:Number = 4;
var size:Number = 100;
function rotationX() {
this._y = Math.sin(angle*Math.PI/180)*radius+centar.y;
//if size equals radius then sizes are the same
z = Math.cos(angle*Math.PI/180)*radius+size;
this._xscale = this._yscale=z;
angle += speed;
}
_root.MC.onEnterFrame = rotationX;
but i want to rotate square.for that i need 4 points(actually angles because im using sin and cos), and then i need to rotate each point individualy and connect the points. but i doesn
t work. if anybody knows the solution please tell. any other ways of rotating a square(around x axis of course)are also welcome
here is the code i wrote:
//vars
var point:Array = new Array();
var speed:Number = 4;
var radius:Number = 100;
var centar:Object = new Object();
centar.x = 250;
centar.y = 250;
_root.createEmptyMovieClip("square", 1);
_root.square.lineStyle(2, 0xff0000, 100);
//square points, they are actually angels
point = [135, 45, 315, 215];
function rotation() {
for (n=0; n<=point.length; n++) {
y = Math.sin(point[n]*Math.PI/180)*radius+centar.y;
z = Math.cos(point[n]*Math.PI/180)*radius+size;
this._xscale = this._yscale=z;
point[n] += speed;
if (n == 0) {
this.moveTo(z, y);
} else {
this.lineTo(z, y);
}
point[n] += speed;
}
}
_root.square.onEnterFrame = rotation;