topical media & game development
lib-flex-animation-code-01-BitmapCollision-Star.ax
lib-flex-animation-code-01-BitmapCollision-Star.ax
(swf
)
[ flash
]
flex
package
{
import flash.display.Sprite;
public class @ax-lib-flex-animation-code-01-BitmapCollision-Star extends Sprite
{
public function @ax-lib-flex-animation-code-01-BitmapCollision-Star(radius:Number, color:uint = 0xFFFF00):void
{
graphics.lineStyle(0);
graphics.moveTo(radius, 0);
graphics.beginFill(color);
// draw 10 lines
for(var i:int = 1; i < 11; i++)
{
var radius2:Number = radius;
if(i % 2 > 0)
{
// alternate the radius to make spikes every other line
radius2 = radius / 2;
}
var angle:Number = Math.PI * 2 / 10 * i;
graphics.lineTo(Math.cos(angle) * radius2, Math.sin(angle) * radius2);
}
}
}
}
(C) Æliens
18/6/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.