Revision: 20643
at November 20, 2009 12:24 by sottenad

Initial Code
```/*
Steve Ottenad - Nov 20, 2009 - AS3 Circle Drawing/ Clock Wipe Snippet

This Snippet works by drawing and then fading a succession of small triangles to make a circle/polygon.
It relies on TweenMax, a free tweening engine found at http://blog.greensock.com/tweenmax/.

Parameters:
centerX        (Number) - The X coordinate of the center of the circle to be drawn.
centerY        (Number) - The Y coordinate of the center of the circle to be drawn.
increment      (Number) - The amount of degrees you want to add each time a wedge is drawn. If increment = 2, then 180 wedges will be drawn (360/2). If increment = 36, then 10 wedges will be drawn (360/10).
timeIncrement  (Number) - The amount of milliseconds between each wedge being drawn.
Container   (MovieClip) - The containing element.

Sample Usage: drawCircle(centerX, centerY , radius, increment , timeIncrement, container);
*/

function drawCircle(centerX:Number, centerY:Number, radius:Number, increment:Number, timeIncrement:Number, container:MovieClip){

//Define Variables
var iniX:Number = centerX;
var iniY:Number = centerY;
var increment:Number = increment;
var totalDegrees:Number = 0;
outline.visible = true;

//Create Timer

//Start Drawing
container.graphics.moveTo(iniX, iniY);
function drawSegment(e:TimerEvent){
degInRad = totalDegrees * (Math.PI / 180);
degInRad1 = Number(totalDegrees+increment) * (Math.PI / 180);
//Find X,Y

var wedge:Sprite = new Sprite();
wedge.alpha = 0;

//Define Color
wedge.graphics.beginFill(0x000000);
wedge.graphics.moveTo(iniX, iniY);
wedge.graphics.lineTo(x1, y1);
wedge.graphics.lineTo(x2, y2);
wedge.graphics.lineTo(iniX, iniY);

//Fade In (Time == 1 in this example
TweenMax.to (wedge, 1, {alpha:1});

totalDegrees+= increment
;
}else{
}
}
}```

Initial URL
`http://www.steveottenad.com`

Initial Description
`This is a snippet that will animate in a circle in a clockwise fashion based on the parameters the function is passed. It can be used to create a circular or clock wipe when used as a mask.`

Initial Title
`Create a fading circular mask`

Initial Tags
`actionscript, animation, 3`

Initial Language
`ActionScript 3`