ActionScript 3 AS3:圆饼派

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3:圆饼派相关的知识,希望对你有一定的参考价值。

[SWF(width=400,height=400,backgroundColor=0xEFEFEF,frameRate=30)]
 
const TWO_PI:Number = Math.PI * 2;
 
var resolution:Number = 50;
var step:Number = TWO_PI / resolution;
var maxIndex:int = 0;
 
var coords:Vector.<Number> = new Vector.<Number>();
var drawCommands:Vector.<int> = new Vector.<int>();
 
// populate vectors
for (var i:Number = 0; i <TWO_PI + step; i += step){
    coords.push(100 * Math.cos(i));
    coords.push(100 * Math.sin(i));
    drawCommands.push(GraphicsPathCommand.LINE_TO);
}
 
var circleSegment:Shape = new Shape();
circleSegment.x = circleSegment.y = 200;
addChild(circleSegment);
 
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
    with (circleSegment.graphics) {
        clear();
        beginFill(0x000000);
       
        // count by two, up to coords.length (drawCommands is exactly half the length of coords)
        maxIndex =  Math.ceil((mouseX / stage.stageWidth)  * drawCommands.length) * 2;
 
        drawPath(drawCommands, coords.slice(0, maxIndex));
    }
}

以上是关于ActionScript 3 AS3:圆饼派的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 AS3 TextField和StyleSheet示例(在ActionScript中创建)

[ActionScript 3.0] AS3.0 水面波纹效果

ActionScript 3 AS3:使用SWFObject2和AS3传递变量

ActionScript 3 克隆数组(AS3)

ActionScript 3 AS3序列化

ActionScript 3 As3初始上限