开发者

AS3 Circling the stage

I am trying to have flash draw a line from the center of the stage out and increment around the stage. Not sure what math I would use to do this though. So far I have the line going out to a certain point but not sure how to change that point so that it circles around whatever the dimensions of my stage would be.

So far I have this:

var linetox=0;
var linetoy=0;
var _stage=this;
var _stage_center_x = stage.stageWidth/2;
var _stage_center_y = stage.stageHeight/2;
trace(_stage_center_x);
function enterframe(e:Event):vo开发者_Go百科id {
    linetox+=10;
    linetoy+=10;
    var lineDrawing:MovieClip = new MovieClip();
    this.addChild(lineDrawing);
    lineDrawing.graphics.lineStyle(1);
    lineDrawing.graphics.moveTo(_stage_center_x,_stage_center_y);///This is where we start drawing
    lineDrawing.graphics.lineTo(linetox, linetoy);
}
this.addEventListener(Event.ENTER_FRAME, enterframe);

which obviously moves the destination ending of the line lower and lower, just trying to get it to draw around the screen (like a clock)


var center:Point = new Point(stage.stageWidth/2, stage.stageHeight/2);
var radius:Number = 200;
this.graphics.lineStyle(1, 0x000000, 1);

addEventListener(Event.ENTER_FRAME, drawCirc);

var _x:Number;
var _y:Number;
var _angle = -180;
var _rads = 0;
var rad_conversion:Number = Math.PI / 180;

function drawCirc($evt:Event) {
    _rads = _angle * rad_conversion;
    _x = radius * Math.cos(_rads) + center.x;
    _y = radius * Math.sin(_rads) + center.y;
    if (_angle == -180) {
        this.graphics.moveTo(_x, _y);
    } else {
        this.graphics.lineTo(_x, _y);
    }
    _angle ++;
    if (_angle >= 181) {
        removeEventListener(Event.ENTER_FRAME, drawCirc);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜