package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.StageDisplayState;
import flash.display.NativeWindow;
import flash.events.Event;
import flash.events.MouseEvent;
public class main extends MovieClip {
private var window:NativeWindow=stage.nativeWindow;
private var mysnow:snow;
public function main() {
stage.displayState=StageDisplayState.FULL_SCREEN;
addEventListener(Event.ENTER_FRAME,xh);
close_btn.addEventListener(MouseEvent.CLICK,closefunc);
}
private function xh(event:Event):void {
mysnow=new snow ;
addChild(mysnow);
}
private function closefunc(event:MouseEvent):void {
window.close();
}
}
}
我们还要为snow影片剪辑写一个包,新建一个AS文件,保存在同目录下,名为snow.as,写入以下代码:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class snow extends MovieClip {
private var speedy:Number=Math.random() * 6 2;
public function snow() {
var lastwidth:Number=this.width;
this.width=Math.random() * 5;
this.height*= this.width / lastwidth;
this.y=-5;
this.x=Math.random() * 545;
addEventListener(Event.ENTER_FRAME,xh);
}
private function xh(event:Event):void {
this.y = speedy;
if (this.y > 400) {
removethis();
}
}
private function removethis():void {
removeEventListener(Event.ENTER_FRAME,xh);
parent.removeChild(this);
}
}
}
Ctrl Enter测试就可以看到效果了。
测试文件下载:http://www.jb51.net/files/soft/1_080604010222.rar
效果如下: