Here is a small and simple class I wrote this morning to create an animated rising sun. You can configure the number of segments and the size very easily.
package
{
import flash.display.Sprite;
import flash.events.Event;
public class RisingSun extends Sprite
{
private var _segments :Number = 40;
private var _rad :Number = 730;
public function RisingSun()
{
super();
x = 364;
y = 45;
graphics.clear();
graphics.beginFill(0xFF0000, 0.8);
graphics.drawCircle(0, 0, _rad);
graphics.endFill();
var _angle:Number = Math.PI / _segments;
var a:Number = _angle;
for (var i:Number = 0; i < _segments; i++)
{
var s:Sprite = new Sprite();
s.graphics.clear();
s.graphics.beginFill(0xCC0000, 0.5);
s.graphics.lineTo(Math.cos(a)*_rad, Math.sin(a)*_rad);
a += _angle;
s.graphics.lineTo(Math.cos(a)*_rad, Math.sin(a)*_rad);
s.graphics.lineTo(0, 0);
s.graphics.endFill();
a += _angle;
addChild(s);
}
addEventListener(Event.ENTER_FRAME, _frame);
}
private function _frame(e:Event):void
{
rotation += 0.5;
}
}
}
Recent Comments