Flash 8 making fireworks particle effects

Source: Internet
Author: User
Tags contains
Special effects Flash View address:
http://www.citydna.cn/works/etboy.asp
Make fireworks particle effects with flash 8
The action code is as follows: (code from FLASH8, now learning, 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);
The display canvas of the particle
var bitmapShow2 = Createemptymovieclip ("BitmapShow2", 2). Attachbitmap (BITMAP2,
2);
White sparkle on the display canvas
var m_mousex;
Mouse x coordinates
var M_mousey;
Mouse y coordinates
var sound1 = new Sound ();
The sound of the rising process
var sound2 = new Sound ();
Explosion Sound
var bit_px = new Array (bits);
X-coordinates of the explosion process
var bit_py = new Array (bits);
The y-coordinate of the explosion process
var bit_vx = new Array (bits);
X velocity of the explosion process
var bit_vy = new Array (bits);
The Y-velocity of the explosion process
var bit_sx = new Array (bits);
X-coordinate of the ascent process
var bit_sy = new Array (bits);
The y-coordinate of the ascent process
var bit_l = new Array (bits);
The life time of the particle
var bit_f = new Array (bits);
The sign of a rise or an explosion.
var bit_p = new Array (bits);
Sign of random white sparkle
var bit_c = new Array (bits);
Particle color
Init ();
function init () {
Sound1.attachsound ("Sound1");
Sound2.attachsound ("Sound2");
bits = 500;
The total maximum number of particles
Bit_max = 50;
Number of particles in one occurrence
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);
White Sparkle Clear
Bitmap2.applyfilter (Bitmap, Bitmap.rectangle, new Point (0, 0), con);
Rend ();
Bitmap1.applyfilter (Bitmap1, Bitmap1.rectangle, New Point (0, 0), con);
Blur Filter
};
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;
BIT_L[L1] = Int (math.random () *100) +100;
BIT_P[L1] = Int (math.random () *3);
if (random (4) = = 0) {
BIT_C[L1] = 0xFFFFFF;
} else {
BIT_C[L1] = J1;
}
BIT_SX[L1] = M_mousex;
BIT_SY[L1] = rect.height-5;
BIT_F[L1] = 2;
if (++k1 = = Bit_max) {
Break
}
}
Sound1.start (0);
}
};
function rend () {
var Flag:boolean = false;
var Flag1:boolean = false;
var Flag2:boolean = false;
for (var k = 0; k<bits; k++) {
Switch (Bit_f[k]) {
Case 1:
Explosion process
BIT_VY[K] + + = math.random ()/100;
Bit_px[k] + = bit_vx[k];
Bit_py[k] + = bit_vy[k];
bit_l[k]--;
if (bit_l[k] = = 0 | |!rect.contains (BIT_PX[K), bit_py
[K])) {
Bit_c[k] = 0x000000;
Bit_f[k] = 0;
else if (bit_p[k] = = 0) {
if (int (math.random () *2) = = 0) {
Bit_setwhite (int (bit_px[k]), int
(Bit_py[k]), 0xFFFFFFFF);
}
Bit_set (int (bit_px[k]), int (bit_py[k]), int
(Bit_c[k]));
} else {
Bit_set (int (bit_px[k]), int (bit_py[k]), int
(Bit_c[k]));
}
Break
Case 2:
Ascent Process
BIT_SY[K]-= 5;
if (Bit_sy[k]<=bit_py[k]) {
Bit_f[k] = 1;
Flag2 = true;
}
if (int (math.random () *20) = = 0) {
var i = Int (math.random () *2);
var j = Int (Math.random () *5);
Bit_set (Bit_sx[k]+i, Bit_sy[k]+j, 0xFFFFFF);
}
Break
}
}
if (Flag2) {
Sound2.start (0);
}
}
function Bit_set (I:number, J:number, K:number) {
Bitmap1.setpixel (I, J, K);
}
function Bit_setwhite (I:number, J:number, K:number) {
Bitmap2.setpixel32 (I, J, K);
White Sparkle
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.