Easy to implement flash dynamic background

Source: Internet
Author: User
Tags copy eval implement modify range
Dynamic

Today we introduce a few flash common dynamic background of the simple production method, the main use of random numbers, simple steps, but the effect is very good.

  One, the swaying vertical line

< param name= "wmode" value= "window" >
Download learning from the original file

This effect is very common, in fact, the implementation is relatively simple, mainly through the control of the MC x coordinates to achieve.

Create a new MC, named Line_g, draw a vertical line, coordinate (0,0).

  Note: the initial coordinates of each MC in this flash that requires control coordinates are important, or you'll find it hard to figure out where the damn MC went, even the ordinary flash, we'd better make some standard, so it looks very clear and easy to check.

Then create a new MC, named line_a, drag the Line_g into the (attention coordinates) and bundle the following as on the line_g :

   onclipevent (load) {
Speed = Random (40)-20; //Set the initial value of the move speed to 20 to 20
round =;
}
Onclipevent (enterframe) {
if (_x<0) {
_x = 450;    
}
if (_x>450) {
_x = 0;

//above two judgment statements are to avoid the MC exceeding the playback range, where "450" is the width of the FLA file

if (i _x + = speed;
i++;
//Give it a certain run time to keep a certain speed
//numerical 20 to maintain the cycle of this speed, you can set the
} else {
speed = random -20;
i = 1;
//new speed given after time
}

Go back to the scene, drag a few line_a, (5 in this case), set all their x coordinates to half the height of the FLA file, and the preview gets the effect. Careful observation shows that they can change both speed and direction at the same time.

We can further modify the speed change cycle of each MC to be different (the change period 20 is fixed): onclipevent (load) {...} Between the round =; Modify to round = random +5 ;, and at the last else{...} Also adds round=random +5 , so the change is more elusive.

If you like, you can further randomly adjust the color and width of the vertical bar in the scene, leaving you to think and experiment.

Second, flashing square

This effect is better suited to arrange it in a corner, or to make a star-like random appearance anywhere, it depends on your own preferences. No use of setproperty in the production, but through the random number of jumps to the fade box MC A frame to achieve the purpose of random flashing.


Download the original document learning

First create a new Graphic(graphical symbols) named Changer_g,Select the Rectangle tool and press ShiftKey to draw a square of the appropriate size (attention coordinates), double-click the edge of the square, select all the sideline, ctrl+xCut down (temporarily stored on the clipboard).
New MC, named Changer_m,Dragged into Changer_g,Create KeyFrames in frame 20th (or at random frames), and frame the 20th Changer_gChange the transparency to 0, creating MotionAnimation.

New MC, named changer_a, drag into changer_m(Note the coordinates), Ctrl + V"Release" a square border that has been placed on the clipboard for a long time, and that border should be exactly the same as changer_mOverlap, if not so please adjust.

Selected changer_m, bundled as:

  Onclipevent (enterframe) {
if (i<5) { //You can also modify this change period as needed
      gotoAndStop (Random (20)); //This number is the total frame number of the Changer_m
      i++;
}else{
      I=1;
}
}

Then drag a couple of changer_ainto the scene and set the position according to your preference. The effect is done.

  Three, the arrows of random running

This effect is achieved by using random functions to control the position, size, and transparency of the MC that moves from left to right.


Download the original document learning

First of all, make an arbitrary shape Graphical Symbols(graphic) is named Basic_g, here to signal that we have simply done a ">" symbol, you can carefully draw a beautiful arrow, the effect will be better.

and create a new one. Movie Clips(MovieClip) is named basic_m, will just be the graphic symbol Basic_gDrag into (coordinate 0,0). To build keyframes in frame 20th (this is not a random set, I'll explain them further in the following as), drag the graphic symbol to the right horizontally. Create from frame 1th through frame 20th MotionAnimation, and then create frames 5th and 15th as keyframes (press F6 When selected), and select the graphic symbols in frame 1th and 20th frames to change the opacity to 0%. This allows us to create a fade-fade-right MC.

and create a new one. Movie ClipsNamed as basic_a, will just do the basic_mDrag in (coordinate 0,0) and name its inctance name (instance name) as objTo control it in as, creating a content frame in the second frame (shortcut key F5).
In basic_aTo create a new layer in the Frame 1thAs in the bundle below, which is the core part of this effect.

   if (i<=20) {
/*
The number 20 here is the same as the number of frames mentioned earlier in the basic_m. Alternatively, you can set the number of integers in the frame, because the depth of the MC in the following copy statement is determined by I, that is, when the 20th MC copy is completed, it will start at 1, so that the MC with a depth of 1 in the previous copy will be overwritten. And then also just passed 20 frames, the MC has completed a playback process. If the two numbers are not equal there will be the MC has not been played to complete disappeared or play to the second part of the MC disappeared.
*/
Duplicatemovieclip ("obj", I, I);
/*
To copy a statement, the syntax is:
Duplicatemovieclip (target,newname,depth);
Target: Name of the MC being copied
NewName: The name of the MC that was copied
Depth: The depth of the duplicated MC
If the depth is the same, then the new MC will cover the old MC
*/
eval (i). _x = Random (250);
/*
Set a random number with an X coordinate of 0-250 for the MC
(The upper limit is about the FLA file width minus the distance basic_m basic_g)
*/
eval (i). _y = Random (90); //Set the random number of the MC's y-coordinate to 0-90 (the upper limit is slightly greater than the FLA file's height)
Tint = random (50) +50; //Custom variable tint to save a random number of 50-100

eval (i). _xscale = tint;
eval (i). _yscale = tint;
eval (i). _alpha = tint;
/*
Set the MC's X, y ratio and transparency as equal values, so that the size of the MC change in proportion to the transparency of the changes in direct proportion, so that there appears to be a layered sense.
*/
i++;
} else {
i = 1;
}

set frame 2nd also as a keyframe (shortcut key F6), bundled with the following as:
  gotoAndPlay (1);

Back to the scene, drag the basic_a into the top left corner (note that it's just beyond the scene range). OK, now press the Ctrl+enter test, dazzle it.



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.