Flash8 blendmode--Light and shadow transformation

Source: Internet
Author: User
Tags copy cos reference sin

Demo file :



Production idea : Create a movie clip, which contains five frames, each frame with a different color of the ball, in the code we will use ActionScript to control its jump frame has been positioned in different colors of the ball, to achieve the different color of the ball overlap each other, and copy in the scene, control its automatic movement through ActionScript, and apply the fusion effect.

Action method:
1. Create a new Flash document, the file's scene size is set to 590*350. The background is black. The frame rate is set to 31, and it is saved as a blendmode3.fla.
2. Open the new Blendmode3.fla. In the home scene to draw a 38*38 size of the garden-shaped two-dimensional shape, press the SHIFT+F9 open the color mixer, select the radial filling, when the selection of blue, as shown in the following figure.



Note the color mixer on the right, in the slider below, our left side is blue, the right side is also blue, but its transparency is 0, after filling the effect as shown in the following figure.



Note that the size of this garden is currently magnified to see the effect, its original size is 38*38.
3. Select this garden press the F8 key, convert it to a graphical symbol, and name it blue. Also note its registration point. Place the registration point in a central location. As shown in the following figure.



4. After we have established the blue symbol, we need to create the other 4 kinds of balls in the same way, in this case we created the following balls of several colors.



5. There is also a simple way to create a different color ball, select the blue ball we just created, right click to select Direct Copy. The color is then modified inside the copied graphic element.
6. After creating several small balls, we remained empty at the home scene. If the scene has a graphic symbol to delete. Then press CTRL+F8. Create a new movie clip, and we'll name it clip. Then drag the five different colored ball elements we've just built from the library to the frames in the clip movie clip, as shown in the following illustration.



7.ok. After completing this step, return to the main scene, select the clip movie clip that we just created in the library, and right-click the Select link. The Link Identification window opens. As shown in the following figure.

In the open window, select Export for ActionScript, and then enter the exit partical name at the link identification. Are you sure. The name of the link we created here is for us to use Attachmovie to paste and copy operations when we add code to the main frame.
8. After completing the above operation. Select the first frame on the main scene, press F9, and open the ActionScript panel. We are going to enter the following code:

Define Center Location
var cx = 180;
var cy = 180;
Set the Loop 20 times to copy a movie from the library that has a link ID of partical.
for (var i = 0; i<20; i++) {
Copy a movie clip with a reference name of MC.
var mc = This.attachmovie ("partical", "P" +i, I);
With (MC) {
Initializes the location of the movie clip, noting that at this point cx,cy is used to adjust the offset position of the MC instance.
_x = Cx+math.random () *60;
_y = Cy+math.random () *60;
}
For MC application Fusion mode type "Add"
Mc.blendmode = "Add";
Setting the angle random value of MC instance
MC.TX = random (360);
Mc.ty = random (360);
To set an incremental random value for the MC angle
Mc.xtempo = Math.random ()/10;
Mc.ytempo = Math.random ()/10;
Set the speed random value of MC instance
Mc.xd = Math.random () *10+1;
Mc.yd = Math.random () *10+1;
mc.x0 = mc._x;
Mc.y0 = mc._y;
Jumps to the specified frame to transform the different colors on the ball.
Mc.gotoandstop (Random (5) +1);
Let the particles move by onenterframe the loop.
Mc.onenterframe = function () {
This.tx + = This.xtempo;
This.ty + = This.ytempo;
this._x = This.x0+math.sin (this.tx) *this.xd;
this._y = This.y0+math.cos (this.ty) *this.yd;
};

}

9, test your video and you will see the following effects:



Explanation Code:
First of all, from the code on the entire segment, we actually only use a for loop. The purpose of this for loop is to copy a movie clip with 20 linked names, partical. Then we initialize and control the copied particle reference MC in the internal loop. The first two lines are used to adjust the position of all particles relative to the screen,
Define Center Location
var cx = 180;
var cy = 180; Next, we start with the inside of the For loop, we divide it into chunks, initialize the copied particles, and add the dynamic properties for the particle instance MC to prepare for the subsequent control movement. The third block uses the Onenterframe loop to control movement.

Initialize the copied particles:
Copy a movie clip with a reference name of MC.
var mc = This.attachmovie ("partical", "P" +i, I);
With (MC) {
Initializes the location of the movie clip, noting that at this point cx,cy is used to adjust the offset position of the MC instance.
_x = Cx+math.random () *60;
_y = Cy+math.random () *60;
This piece of code, now we are familiar with, we pass the top for loop 20 times. Copy the partical of the link name in the library into the scene. The way we use it is Attachmovie, the copy of the movie clip is renamed "P" +i, which means that you copy the result should be p0,p1,p2,p3.....p19, And all of these movie clips we give it an instance called MC. It represents all the copied movie clips. Within the with, we begin to specify the initial position of these particles. Notice that we use the cx,cy at this time and add a random number of 60, which means that the material is initialized in a position between 180-240.

adding dynamic properties to the particle instance MC:
For MC application Fusion mode type "Add"
Mc.blendmode = "Add";
Setting the angle random value of MC instance
MC.TX = random (360);
Mc.ty = random (360);
To set an incremental random value for the MC angle
Mc.xtempo = Math.random ()/10;
Mc.ytempo = Math.random ()/10;
Set the speed random value of MC instance
Mc.xd = Math.random () *10+1;
Mc.yd = Math.random () *10+1;
mc.x0 = mc._x;
Mc.y0 = mc._y;
Jumps to the specified frame to transform the different colors on the ball.
Mc.gotoandstop (Random (5) +1); At the beginning of this code Mc.blendmode = "Add" is the focus of our integration mode, if not this will not come out after the superposition of the fusion effect. But the first thing to do is that we have to deal with basic particle activity, so we're all used to the last filter or fusion pattern. In this code, all are prepared for the third paragraph loop. There are two sentences which are used to make the increment random value of the angle. This angular increment value is actually a change in the angle that is added to the onenterframe cycle. Make the effect more obvious. The last sentence in this section is also the focus because we have five different colored balls in the partical movie clip, and we have a random jump command to switch between the different color balls.

Onenterframe Loop to control movement:
Let the particles move by onenterframe the loop.
Mc.onenterframe = function () {
This.tx + = This.xtempo;
This.ty + = This.ytempo;
this._x = This.x0+math.sin (this.tx) *this.xd;
this._y = This.y0+math.cos (this.ty) *this.yd;
In this code, it is crucial to apply the previously defined dynamic properties to the Onenterframe loop.
this._x = This.x0+math.sin (this.tx) *this.xd;
this._y = This.y0+math.cos (this.ty) *this.yd;
Where this.tx,this.ty,this.xd,this.yd. All are the dynamic properties defined previously. We used the sin () and cos () method to make each particle have a circular motion path of its own.

Ok. In the whole generation, we see that using the Fusion mode Blendmode only one row, but here it is particularly important, plus and remove the effect is very different.

Now you can test your film.
Next we have to make a change on the basis of the above. See how the effect will be different.
We are now going to increase the size and range of the particles. Code to make the following modifications.
Define Center Location
var cx = 0;
var cy = 0;

Set the Loop 20 times to copy a movie from the library that has a link ID of partical.
For (var i = 0; i<100; i++) {
Copy a movie clip with a reference name of MC.
var mc = This.attachmovie ("partical", "P" +i, I);
With (MC) {
Initializes the location of the movie clip, noting that at this point cx,cy is used to adjust the offset position of the MC instance.
_x = Cx+math.random () *590;
_y = Cy+math.random () *350;
_xscale = _yscale = Math.random () *5+1;
}
For MC application Fusion mode type "Add"
Mc.blendmode = "Add";
Setting the angle random value of MC instance
MC.TX = random (360);
Mc.ty = random (360);
To set an incremental random value for the MC angle
Mc.xtempo = Math.random ()/10;
Mc.ytempo = Math.random ()/10;
Set the speed random value of MC instance
Mc.xd = Math.random () *10+1;
Mc.yd = Math.random () *10+1;
mc.x0 = mc._x;
Mc.y0 = mc._y;
Jumps to the specified frame to transform the different colors on the ball.
Mc.gotoandstop (Random (5) +1);
Let the particles move by onenterframe the loop.
Mc.onenterframe = function () {
This.tx + = This.xtempo;
This.ty + = This.ytempo;
this._x = This.x0+math.sin (this.tx) *this.xd;
this._y = This.y0+math.cos (this.ty) *this.yd;
};

}
The italic bold code is the position we modified, we added the number of particles, and added the _xscale._yscale. The random value of scaling, which amplifies the particles and increases the coincidence of the particles. The effect is as follows:



Next we make the changes on the basis of this code. We have to change the fusion mode, we will get different results. The following code.
Define Center Location
var cx = 0;
var cy = 0;
Set the Loop 20 times to copy a movie from the library that has a link ID of partical.
for (var i = 0; i<100; i++) {
Copy a movie clip with a reference name of MC.
var mc = This.attachmovie ("partical", "P" +i, I);
With (MC) {
Initializes the location of the movie clip, noting that at this point cx,cy is used to adjust the offset position of the MC instance.
_x = Cx+math.random () *590;
_y = Cy+math.random () *350;
_xscale = _yscale = 140 * math.random () *5+1;
}
For MC application Fusion mode type "Add"
mc.blendmode = "Hardlight";
Mc.cacheasbitmap = true;

Setting the angle random value of MC instance
MC.TX = random (360);
Mc.ty = random (360);
To set an incremental random value for the MC angle
Mc.xtempo = Math.random ()/10;
Mc.ytempo = Math.random ()/10;
Set the speed random value of MC instance
Mc.xd = Math.random () *10+1;
Mc.yd = Math.random () *10+1;
mc.x0 = mc._x;
Mc.y0 = mc._y;
Jumps to the specified frame to transform the different colors on the ball.
Mc.gotoandstop (Random (5) +1);
Let the particles move by onenterframe the loop.
Mc.onenterframe = function () {
This.tx + = This.xtempo;
This.ty + = This.ytempo;
this._x = This.x0+math.sin (this.tx) *this.xd;
this._y = This.y0+math.cos (this.ty) *this.yd;
};

}

Italic bold code for the location we have modified, we increase the zoom, while the fusion mode for hardlight. Of course you can try other fusion methods, and we have added Mc.cacheasbitmap = True. This is the fastest way to speed up our movie clips. The effect of the test is as follows.



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.