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.49028c.com/files/soft/1_080604010222.rar
效果如下:
新聞熱點
疑難解答