Tutorial | Effects animations are as follows:
Click here to download the source file
One, a new flash document, the background is black, size 800*600.
Two
1. Press O use the Ellipse tool, hold down SHIFT and drag to draw a borderless circle on the stage.
2, open the "color mixer", with "radioactive" fill, as shown:
Third, select the circle, according to F8 into components, behavior: Film clips, that is, the circle into the MC, and named "Worms."
Four, select the home scene 1th frame, open the action panel, write As:for (i=1;i<=20;i++) {//cycle, 20 to copy the number of "worms."
Worm. Duplicatemovieclip ("worm" +i,i);//Copy 20 worms.
With (this["worm" +i]) {
_x = random (stage.width);//stage.width is the stage width.
_y = random (stage.height);//stage.height for stage height.
}//Let the worms spread in every corner of the stage.
}
Select the "Bug" MC, open the Action panel, write:
Onclipevent (load) {
v = 3;//Speed
_rotation = random (360);//Let the worm rotate to any angle.
}
Onclipevent (enterframe) {
K = Math.pow ( -1,random (2));//randomly generate 1 and-1.
_rotation + = K*random (11);//Let the worm rotate between 10 and 10.
A = _rotation*math.pi/180;//converts an angle to radians. (Detailed view above)
DX = Math.Cos (a) *v;
DY = Math.sin (a) *v;
The amount of movement of the horizontal ordinate. (Detailed view above)
_x = + dx;
_y + dy;
Limit the range of insect movements. Focus
Resolution: Determine the scope first. (Wide: 50--750; High: 50--550)
if (_x <= && dx<0 | | _x >= 750 && dx>0) {
_rotation = math.atan2 (DY,-DX) *180/math.pi;
When the}//exceeds the limit, the DX is changed according to the above conditions,
And the rotation angle is changed with the math.atan2 to change the direction of motion.
As shown in Figure 6:
if (_y <= && dy<0 | | _y >=) && dy>0) {
_rotation = math.atan2 (-DY,DX) *180/math.pi;
The principle of}//is ditto.
Six, press Ctrl+enter debugging, see effect:)