package { import flash.display.MovieClip; import flash.filters.GlowFilter; import flash.utils.Timer; import flash.events.TimerEvent; [SWF(width="1024",height="768")] /* *author : SinSoul *blogs: http://www.cnblogs.com/sinsoul */ public class xingx extends MovieClip { var arr:Array=[]; var timer:Timer=new Timer(1000); public function xingx() { for (var i:int=0; i<150; i++) { var aa:xing=new xing(); addChild(aa);//把括号内的东西添加在舞台上; aa.x=Math.random()*1000;//把五角星的X坐标随即 aa.y=Math.random()*700; var Gf:GlowFilter=new GlowFilter(0xffffff*Math.random(),1,15,15); aa.filters=[Gf];//刚开始给星星赋予一个颜色 //aa.gotoAndPlay(int(Math.random()*30));//每运行一次则随即从某一帧开始播放 aa.scaleX=aa.scaleY=aa.alpha=Math.random()*0.7+0.3;//星星X和Y的坐标随即落到0.3至1之间 arr.push(aa); } timer.addEventListener(TimerEvent.TIMER,onTimer); timer.start(); } function onTimer(e):void { for (var i:int=0; i<arr.length; i++) { var Gf:GlowFilter=new GlowFilter(0xffffff*Math.random(),1,13,13); arr[i].filters=[Gf]; } } } } package { import flash.display.Sprite; /* *author : SinSoul *blogs: http://www.cnblogs.com/sinsoul */ public class Star extends Sprite { public function Star(radius:Number, color:uint = 0xFFFF00):void { //graphics.lineStyle(0); graphics.moveTo(radius, 0); graphics.beginFill(color);a // 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); } } } }