Click the animation with the mouse to see the effect of divergence.
Demo Effect:
Click here to download the source file
What's the effect? If you feel good, try it! The production steps are as follows.
First start flash, I am using Flash 8, then create the Flash document, and then press CTRL+J to modify the document properties.
Then press Ctrl+f8 to create a new movie clip symbol, the name is fragment, and then draw a white circle, as far as the size can be.
Then return to the main scene, select the first frame, and enter the following code.
/* Define four global variables, define location
_global.gleft = 0;
_global.gtop = 0;
_global.gright = Stage.width;
_global.gbottom = Stage.height;
/* 5 variables define the speed, maximum, minimum, number of components.
var maxspeed:number = 25;
var minsize:number = 4;
var maxsize:number = 10;
var minfragments:number = 50;
var maxfragments:number = 150;
/* function to return a number between the maximum and the minimum
function Randrange (Min:number, Max:number): number {
var randomnum:number = Math.floor (Math.random () * (Max-min + 1)) + min;
return randomnum;
}
/* Main program Fragment * *
OnMouseDown = function (): Void {
var totalfragments:number = Randrange (minfragments, maxfragments);
var Fragment_mc:movieclip;
var depth:number = this.getnexthighestdepth ();
for (var i:number = 0; i < totalfragments; i++, depth++) {
FRAGMENT_MC = Attachmovie ("Fragment", "fragment" + depth, depth);
fragment_mc._x = _xmouse;
fragment_mc._y = _ymouse;
Fragment_mc._width = Fragment_mc._height = Randrange (MinSize, maxSize);
while (!fragment_mc.speedx) {
Fragment_mc.speedx = Randrange (-maxspeed, maxspeed);
}
while (!fragment_mc.speedy) {
Fragment_mc.speedy = Randrange (-maxspeed, maxspeed);
}
Fragment_mc._alpha = Randrange (10, 100);
Fragment_mc.cacheasbitmap = true;
Fragment_mc.onenterframe = function (): Void {
This._x + = This.speedx;
This._y + = This.speedy;
if (this._x < Gleft | | this._x > Gright | | this._y < gtop | | this._y > Gbottom) {
This.removemovieclip ();
}
};
}
};