flash观看地址:
http://www.citydna.cn/works/etboy.asp以Flash 8制造烟花粒子特效
动作代码如下:(代码来自flash8,现学现用,HOHO~~)
Stage.scaleMode = "noScale";
import flash.display.BitmapData;
import flash.filters.ConvolutionFilter;
import flash.geom.Rectangle;
var con = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 30, 1, 1, 1, 1], 38);
var rect:Rectangle = new Rectangle(0, 0, Stage.width, 200);
var bitmap1 = new BitmapData(rect.width, rect.height, false,0x00000000);
var bitmap2 = new BitmapData(rect.width, rect.height, true,0x00000000);
var bitmapShow1 = createEmptyMovieClip("bitmapShow1", 1).attachBitmap(bitmap1,
1);
//粒子的显示画布
var bitmapShow2 = createEmptyMovieClip("bitmapShow2", 2).attachBitmap(bitmap2,
2);
//白色闪光点的显示画布
var m_mouseX;
//鼠标x坐标
var m_mouseY;
//鼠标y坐标
var sound1 = new Sound();
//上升过程的声音
var sound2 = new Sound();
//爆炸声音
var bit_px = new Array(bits);
//爆炸过程的x坐标
var bit_py = new Array(bits);
//爆炸过程的y坐标
var bit_vx = new Array(bits);
//爆炸过程的x速度
var bit_vy = new Array(bits);
//爆炸过程的y速度
var bit_sx = new Array(bits);
//上升过程的x坐标
var bit_sy = new Array(bits);
//上升过程的y坐标
var bit_l = new Array(bits);
//粒子的生命时间
var bit_f = new Array(bits);
//是上升还是爆炸的标志
var bit_p = new Array(bits);
//随机出现白色闪光点的标志
var bit_c = new Array(bits);
//粒子颜色
init();
function init() {
sound1.attachSound("sound1");
sound2.attachSound("sound2");
bits = 500;
//总的最大粒子数
bit_max = 50;
//一次出现的粒子数
bit_sound = 2;
for (var j = 0; j<bits; j++) {
bit_f[j] = 0;
}
}
onEnterFrame = function () {
bitmap2.fillRect(new Rectangle(0, 0, rect.width, rect.height),
0x00000000);
//白色闪光点清除
//bitmap2.applyFilter(bitmap, bitmap.rectangle, new Point(0, 0), con);
rend();
bitmap1.applyFilter(bitmap1, bitmap1.rectangle, new Point(0, 0), con);
//模糊滤镜
};
onMouseDown = function () {
m_mouseX = _root._xmouse;
m_mouseY = _root._ymouse;
if (rect.contains(m_mouseX, m_mouseY)) {
var k = int(Math.random()*256);
var l = int(Math.random()*256);
var i1 = int(Math.random()*256);
var j1 = k << 16 | l << 8 | i1;
var k1 = 0;
for (var l1 = 0; l1<bits; l1++) {
if (bit_f[l1] != 0) {
continue;
}
bit_px[l1] = m_mouseX;
bit_py[l1] = m_mouseY;
var d = Math.random()*6.28;
var d1 = Math.random();
bit_vx[l1] = Math.sin(d)*d1/2;
bit_vy[l1] = Math.cos(d)*d1/2;