Flash CS3 - Circular Motion - Rotating Square
ActionScript Code: stage.frameRate=30; //draw square var square:Shape = new Shape(); square.graphics.beginFill(0xFF6600,1); square.graphics.drawRect(-25,-25,50,50); square.graphics.endFill(); square.x=stage.stageWidth/2; square.y=stage.stageHeight/2; addChild(square); //draw circle var circle:Shape = new Shape(); circle.graphics.lineStyle(1,0x00FFCC); circle.graphics.drawCircle(0,0,100); circle.x=stage.stageWidth/2; circle.y=stage.stageHeight/2; addChild(circle); //Animate SquaRE var radius:Number = 100; var speed:Number = .1; var xcenter:Number = square.x; var ycenter:Number = square.y; var degree:Number = 0; stage.addEventListener(Event.ENTER_FRAME,myFunction); function myFunction(e:Event):void { degree += speed; square.x = xcenter+Math.cos(degree)*radius; square.y = ycenter+Math.sin(degree)*radius; }