2

I want to have a circle (maybe a movieclip ) to show a timer which change like this picture :

my goal

And also I need to access its angle in run-time. for example:

function setAngle(degree:Number)

Any suggest ?

Emadpres
  • 3,466
  • 2
  • 29
  • 44

2 Answers2

2

Give this a try:

var circle:Number = Math.PI * 2;
var degree:Number = Math.PI / 180;

var radius:Number = 30;
var shape:MovieClip = _root.createEmptyMovieClip("shape", _root.getNextHighestDepth());

shape._x = 100;
shape._y = 100;
shape._rotation = -90;


function render(chunkAngle:Number):Void
{
    chunkAngle *= degree;

    shape.clear();
    shape.lineStyle(1);
    shape.beginFill(0x6BB0FF);

    shape.lineTo(radius, 0);

    for(var i:Number = circle; i > chunkAngle; i -= degree)
    {
        shape.lineTo(Math.cos(i) * radius, Math.sin(i) * radius);
    }

    shape.lineTo(0, 0);
    shape.endFill();
}


render(45);
Marty
  • 39,033
  • 19
  • 93
  • 162
0

Well you could have a movieclip with enough frames to cover the angles and use gotoAndStop in your setAngle. Not pretty, though I'm not sure how else you could handle that.