Hi guys,
First of all, I am new to AS3. What I am trying to do is to make the ball, rotate in circular form. This is my current code: this is the Circular.as
public class Circular extends Sprite {
private var ball:Ball;
private var centerX:Number = stage.stageWidth / 2;
private var centerY:Number = stage.stageHeight / 2;
private var radiusX:Number = 500;
private var radiusY:Number = 500;
//private var temp:Number = 180;
private static const speed:Number = 0.1;
public function Oval() {
init();
}
private function init():void {
ball = new Ball(40,0x00ff00,180.0);
addChild(ball);
ball.addEventListener(Event.ENTER_FRAME, startMoving(ball,ball.getAngle()));
}
private function startMoving(object:Ball, angle:Number) {
return function(evt:Event){
onStart(object,angle);
}
}
private function onStart(object:Ball,angle:Number){
object.x = centerX + Math.sin(angle) * radiusX;
object.y = centerY + Math.cos(angle) * radiusY;
ball.setAngle(speed);
//trace(ball.getAngle());
}
}
and this is the Ball.as class file
public class Ball extends Sprite {
private var _radius:Number;
private var _color:uint;
private var _angle:Number;
public function Ball(radius:Number,color:uint, angle:Number) {
_radius = radius;
_color = color;
_angle = angle;
init();
}
public function init():void {
graphics.beginFill(_color);
graphics.drawCircle(0,0,_radius);
graphics.endFill();
}
public function getAngle():Number{
return _angle;
}
public function setAngle(speed:Number){
_angle += speed;
}
}
I am sorry, I forgot to mention the problem I am facing now. The problem I have right now is, the ball did not move. Any ideas?