Flash CS3 - Rotating Sunrays Animation
Copy and paste this AS3 code to the first frame of your flash CS3 document. You don't need to create anything on the stage
function CreateRays():Shape {
var ray:Shape = new Shape();
ray.graphics.beginFill(0xFF9900,.5);
ray.graphics.lineStyle(1,0xFF9900,.5);
ray.graphics.lineTo(600,-20);
ray.graphics.lineTo(600,20);
ray.graphics.lineTo(0,0);
ray.graphics.endFill();
return ray;
}
var sun:Shape = new Shape();
sun.graphics.beginFill(0xFF9900,1);
sun.graphics.drawCircle(0,0,30);
sun.graphics.endFill();
//edit this no to change the no of rays :-)
var SunaRays:Number=25;
var rayShapes = new Shape();
var SunGlow:MovieClip = new MovieClip();
for (var i:int = 1; i<=SunaRays; i++) {
rayShapes=CreateRays();
rayShapes.rotation=360/(SunaRays)*i;
SunGlow.addChild(rayShapes);
}
SunGlow.addChild(sun);
addChild(SunGlow);
SunGlow.x=stage.stageWidth/2;
SunGlow.y=stage.stageHeight/2;
//you can change fps here
stage.frameRate=30;
stage.addEventListener(Event.ENTER_FRAME,rotateSun);
function rotateSun(e:Event):void {
//you change speed here
SunGlow.rotation+=1;
}
Comments
I want to use this rays for a banner but i can`t pun them on background. The rays stays on top of everything.
Can you help ?
Work from home India