求AS3.0大神解答:我希望下面这个程序每半个圆就改变一次半径的,可是半径怎么都不改变,这是为什么?
package{importflash.display.Sprite;importflash.events.Event;publicclassHuayuanextends...
package{
import flash.display.Sprite;
import flash.events.Event;
public class Huayuan extends Sprite{
private var angle:Number=0;
private var centerX:Number=275;
private var centerY:Number=200;
private var range:Number=50;
private var speed:Number=.01;
private var xpos:Number;
private var ypos:Number;
private var n:Number=1;
public function Huayuan() {
init();
}
private function init():void{
graphics.lineStyle(1,0,1);
graphics.moveTo(centerX+Math.cos(angle)*range,centerY+Math.sin(angle)*range);
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(event:Event):void{
ypos=centerY+Math.sin(angle)*range;
xpos=centerX+Math.cos(angle)*range;
graphics.lineTo(xpos,ypos);
angle=angle+speed*Math.PI;
if(angle==n*Math.PI){
range=range+10;
n=n+1;
}
}
}
} 展开
import flash.display.Sprite;
import flash.events.Event;
public class Huayuan extends Sprite{
private var angle:Number=0;
private var centerX:Number=275;
private var centerY:Number=200;
private var range:Number=50;
private var speed:Number=.01;
private var xpos:Number;
private var ypos:Number;
private var n:Number=1;
public function Huayuan() {
init();
}
private function init():void{
graphics.lineStyle(1,0,1);
graphics.moveTo(centerX+Math.cos(angle)*range,centerY+Math.sin(angle)*range);
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(event:Event):void{
ypos=centerY+Math.sin(angle)*range;
xpos=centerX+Math.cos(angle)*range;
graphics.lineTo(xpos,ypos);
angle=angle+speed*Math.PI;
if(angle==n*Math.PI){
range=range+10;
n=n+1;
}
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询