开发者

How to add a needle or arrow from the center of pie chart using action script

开发者 https://www.devze.com 2023-01-08 20:48 出处:网络
alt text http://img717.imageshack.us/img717/13开发者_StackOverflow中文版4/piekh.png Here is the pie chart from center of what I need to draw or place needle sort of thing. How to do it?Something like

alt text http://img717.imageshack.us/img717/13开发者_StackOverflow中文版4/piekh.png

Here is the pie chart from center of what I need to draw or place needle sort of thing. How to do it?


Something like the following should work:

var radians:Number = Math.PI;
var radius:Number = 400;
var xpos:Number = Math.sin(radians)*radius;
var ypos:Number = Math.cos(radians)*radius;

var line:Shape = new Shape();
line.x = stage.stageWidth*0.5;
line.y = stage.stageHeight*0.5;
addChild(line);

var g:Graphics = line.graphics;
g.clear();
g.lineStyle(2, 0x000000);
g.lineTo(xpos, ypos);

If you need to convert degrees to radians or radians to degrees you can use:

degrees to radians: (degrees * Math.PI) / 180
radians to degrees: (radians * 180) / Math.PI
0

精彩评论

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