最逼真透明雪花飘落特效[转]

直接上代码:

package{
import flash.display.*;
import flash.events.*;
public class Snow extends Sprite{
  public var radius:Number;
  public var angle:Number;
  public var speed:Number;
  public function Snow(){
   init();
   addEventListener(Event.ENTER_FRAME,enterFrameHandler);
  }
  public function init():void{
   radius=Math.random()*2;
   angle=(Math.random()+0.5)*Math.PI/2;
   speed=Math.random()+1;
   x=Math.random()*550;
   y=0;
   alpha=Math.random();
   graphics.clear();
   graphics.beginFill(0xffffff);
   graphics.drawCircle(0,0,radius);
   graphics.lineTo(100,100);
  }
  public function enterFrameHandler(e:Event):void{
   x+=speed*Math.cos(angle);
   y+=speed*Math.sin(angle);
   if(y>400||x550){
    init();
   }
  }
}
}
Snow.fla:
var num:int=0;
var lable:TextField=new TextField();
lable.textColor=0xffffff;
lable.htmlText = "sliz";
lable.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
lable.x=520;
lable.y=380;
addChild(lable);
stage.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
function enterFrameHandler(e:Event):void {
if (num  addChild(new Snow());
  num++;
} else {
  stage.removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
}
function mouseDownHandler(e:MouseEvent):void {
navigateToURL( new URLRequest ("http://space.flash8.net/space/?534614" ) );
}

你可能感兴趣的:(.net,Flash)