当前位置: 首页 > 图文教程 > Flash动画 > ActionScript > Flash air制作透明雪花特效

ActionScript
Flash as入门(4):AS常用语句
Flash as入门(5):学习AS数组
Flash as入门(6):文本与字符串⒒
Flash AS3鼠标事件使用详解
网页中flash的trace方法输出数据
Flash as入门(11):拖动与碰撞检测
AS教程:随机显示数字
Flash AS文本字段的透明度alpha变换
AS教程:对场景和MC添加鼠标监听
AIR设置:transparent和systemChrome
Flash AS3教程:flash.text.TextField
AS教程:理解变量作用域修饰符(modifier)
ActionScript3.0中类间传值问题解决
ActionScript3.0中类的定义以及类属性
Flash AS3教程:类属性的属性
ActionScript3.0教程:变量
ActionScript3.0教程:方法
ActionScript3.0教程:类的枚举
简单认识Flash as面向对象编程
Flash AS2教程:影片剪辑

ActionScript 中的 Flash air制作透明雪花特效


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-16   浏览: 105 ::
收藏到网摘: n/a

打开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.ruanchen.com/"center">