Easy to make electronic divergence visual effect animation with Flash

Source: Internet
Author: User

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 ();
}
};
}
};



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.