CGArt-中国CGer中的绿色家园
首页 信息动态 原创排行 互动教程 资源千寻 CG人才 CGArt杂志 艺术设计 CG画廊 CG论坛 酷站欣赏 CG搜索 会员中心
Flash air制作透明雪花特效
来源:baidu空间 作者:粉色男孩 编辑:浪漫的季节 发布时间:2008年06月04日 08:43:29

打开FLASH CS3,新建一个FLASH AIR文档,设置窗口模式为透明(设置方法在上篇文章中我已经说过了),创建一个雪花影片剪辑,链接为snow,在场景中创建一个按钮,实例名称为close_btn,在文档类中填写main,保存此文件为snow.fla。新建一个AS文件,放在同目录下,保存为main.as,在其中写入以下代码:

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.webjx.com/files/soft/1_080604010222.rar

效果如下:

 

共有评论0条
更多评论..
作者信息 详细信息
评论人:
验证码:
内容:
 
about us advertisement publish conformity service cooperate associate link site map contact us help jump to the top of page