我想将一条直线(例如代码中的秒针)旋转到特定角度,使其一端固定,我可以旋转它,但它的位置正在改变。如何在 ActionScript 3 中做到这一点?
public function AnalogClockFace(face:Number)
{
this.size = face;
}
public function draw():void
{
currentTime = new Date();
showTime(currentTime);
}
public function init():void
{
this.graphics.clear();
this.graphics.lineStyle(3.0,0x000000,3.0);
this.graphics.beginFill(0xABC123,1.0);
this.graphics.drawCircle(100,500,size);
this.graphics.endFill();
secondHand=new Shape();
secondHand.graphics.lineStyle(2.0,0x000000,1.0);
secondHand.graphics.moveTo(100,((500-size)+5));
secondHand.graphics.lineTo(100,500);
this.addChild(secondHand);
}
public function showTime(time:Date):void
{
var seconds:uint=time.getSeconds();
var minutes:uint=time.getMinutes();
var hours:uint=time.getHours();
this.secondHand.rotation = 180 + (seconds * 6);
this.minuteHand.rotation = 180 + (minutes * 6);
this.hourHand.rotation = 180 + (hours * 30) + (minutes * 0.5);
}
}