Flash production simulation Mechanical Wave animation tutorial

Source: Internet
Author: User
Tags acos sin
Tutorial

I am a high school physics teacher, to flash it also has a period of time, although intermittent, but also learn some things, here first to thank you for your flash friends. In the last some time I tried to do a simulation of the mechanical wave animation, I feel also can (you do not laugh at me), I Baidu a bit, as if there is no relevant tutorials, but also want to write a look at Lianbi, one is to thank flash it, the second is to still at the starting line of your friends, especially high school physics teachers, I hope you can quickly enter the wonderful hall of Flash, this is my first time to write, if there are deficiencies, but also hope that I forgive, less nonsense, the following official start.

Click here to download the source file (source file)

Click here to download the source file (source file)

  A Thinking analysis

From the formation process of mechanical wave, it is because the vibrating particle is driven by the mutual force with the adjacent particles, through the adjacent points of the vibration form to spread out to form mechanical waves, this must solve two problems:

1. Each particle is vibrated according to the Law of Y=acos (ωt+φ)

2, not all the points start moving at the same time, they have a certain phase difference, near the point of the wave first vibration.

  Ii. Methods of implementation

Here I only introduce the simulation of shear wave animation. To make the particle vibrate, we just have to change the Y-direction of the displacement according to the Law Y=acos (ωt+φ), you can use such a statement to achieve

This._y=y0+r*math.cos (J*MATH.PI/180+M)

Description: Y0 is the balance of the y-coordinate position, all the points of the y0 are the same, ω written math.pi/180, is to change the angle to radian system,

  Three Production steps

1. Draw particle pellets (movie clips).

Into the main scene, select the Ellipse tool, set gradient, as shown in Figure 1, hold down the CTRL key and the left mouse button, in the home scene to draw a small ball.

Select the ball, click the right mouse button, select [Convert to Symbol] (or press F8), select the movie clip in the pop-up dialog box, the registration point is selected in the middle, click "OK" button to convert the ball into a movie clip as shown in Figure 2

Select the ball, open the lower right corner of its property panel, named My_mc as shown in Figure 3

2. To achieve the movement of small balls

Select the ball, open the action panel below, and enter the script, as shown in Figure 4

Let me explain this code briefly:

Onclipevent (load) {} indicates that when a clip is displayed on the timeline, K, R, and y0 are initialized, where the initialization of k may be more difficult to understand, which is the name of the movie clip as its value, and what is its name? As we'll see later, its name is actually 0 to n integers, so what is the purpose of this? Please look down:

Onclipevent (enterframe) {} is something that is repeated after the clip is displayed on the timeline

That is K is constantly minus 2 (can be any number), and then use an if statement to judge, if K<=0 set up, start execution statement this._y = Y0+r*math.sin (k*1.5*math.pi/180) to make small ball movement, we can find, k the smaller, the faster meet K <=0, the first move, then we thought the 2nd of the analysis can be achieved, so the next question is to each particle named

3, copy small ball.

Back to the main scene, create a new layer named action, as shown in Figure 5

Select the first frame of the layer, open the Action panel, and write the code, as shown in Figure 6

As you can see, the names of the movie clips copied from the code are from 0 to 50, so you see,

4, Haha, now you can try your results, ctrl+enter, also satisfied?

5. Realize control

To achieve simple control of the above mechanical waves, you must change the code:

(1) Change the Code of Onclipevent (Enterframe) {} to

Onclipevent (enterframe) {
if (_parent.c = = 0) {
if (k<=0) {
this._y = Y0+r*math.sin (k*1.5*math.pi/180);
}
K=k-2;
}
}

Visible just more than a judge, judge only meet C = 0, will execute code k=k-2, will produce small ball movement, C naturally on the button assigned value.

(2), then create a new layer, from the library to drag two buttons on the layer, we can add the statement on the Start button {c=0}, on the pause button, add statement on (release) {c=1}.

So far, basically finished, longitudinal wave? It's about the same. Finally, the source program of this tutorial and a relatively complete mechanical wave code including longitudinal waves are provided for reference.



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.