Flash Animation-A course for making simple pendulum

Source: Internet
Author: User
Tags acos asin copy cos functions
Flash Animation | tutorials

Think of the original animation, really do not know how to start, so this is a beginner's tutorial for the production of simple pendulum animation, should be resolved two aspects of the problem:

One, the simple pendulum itself, this point as long as the use of a good flash drawing tools can

Second, the pendulum vibration, which will be the focus of the tutorial is also difficult

To solve the first problem, make a pendulum (this step of the production of attention to the selection of registration points) first to understand that the pendulum has three parts: cycloid, Pendulum ball, hanging point (ceiling)

(i), cycloid:

1, select the tool area line tool, line thickness default, in the home scene hold down the Shifi key to draw a line of the appropriate length of segments.
2. Select line segment, right key-convert to component-movie clip, its parameters are set in figure, turn it into movie clip

(b), Pendulum ball:

1, select the tool area of the Ellipse tool, hold down the Shifi key, in the home scene draw a circle,

2, open the main scene to the right of the options bar, select Color-mixer, set as shown,

Select a fill color for the pendulum (you can also choose from the color selection area on the left), select the Paint Bucket tool in the selection area of the tool, and fill in the color for the pendulum ball.

3. Select small ball, right key-convert to symbol-movie shadow clip, its parameter is set in figure, convert it into movie clip

4, add some effect to it: Select the ball, open the work area under the filter options (flash8.0), add a projection effect, set as shown

Effect as shown

(iii) Hanging point (ceiling THB)

Select the line tool for the tool area, line thickness by default, in the home scene, hold the Shifi key level to draw an appropriate length of the line as the ceiling, the same press and hold the Shifi key to draw a diagonal line, using the copy, Paste function, make many diagonal, combined into the schematic diagram of the ceiling, select these line lines, right Key- into a component-movie clip, with its parameters set in the diagram,

Turn it into a movie clip, the effect is as shown,

At this point, the basic components are made, followed by a combined pendulum:

1, delete the main scene of all components, in the first frame to drag a cycloid, and then drag the ball (the goal is to let the pendulum ball in the cycloid upper), adjust the position, and in its property column named Bq, BX, as shown

2, at the same time select the Cycloid, Pendulum ball, right-conversion to components-film clips, its parameters as set in the diagram, convert it into a film clip, made into a pendulum,

And then drag the ceiling elements into a complete pendulum, the effect is as shown

The making of the pendulum is over (drink water first)

Then solve the second problem and let the pendulum move.

Here we need to use the physical pendulum cycle formula and the vibration equation X=acos (ωt+α), but we know that the vibration of a simple pendulum is actually carried out on a circular arc, that is to say, in a circular arc of motion at the same time its x to meet the vibration equation X=acos (ωt+α), how to achieve it,

There is a requirement in physics. That is the pendulum swing angle can not be too big, generally not more than 10 degrees, otherwise it is not harmonic, accordingly, when we deal with the arc (BDC) as a straight line (BOC) processing, good, the key steps to come, from the figure that the pendulum pendulum angle bao, The horizontal direction of the distance for BO, corresponding angle B=arcsin (BO/AB), AB for the Pendulum, X=bo, and this is the pendulum to rotate the angle, OK, we can add code for the pendulum

1. Name the pendulum at the top of the pendulum.

2, add two new floors. A layer named button, used to put the control button, a layer named as, add code to the as layer

Initialization: A0 is the first phase, A is amplitude, g is the gravitational acceleration
a0 = 90;
t = 0;
A = 20;
g = 9.8;
L for the length of the cycloid
L = db.bx._height;
Periodic t is the periodic formula of a simple pendulum
T = 2*math.pi*math.sqrt (l/g);
The action to proceed to the frame
This.onenterframe = function () {
Make a judgment first, if M=1, then execute, this step is to control him to make
if (m = = 1) {
Vibration equation
x = A*math.cos (2*MATH.PI*T/T+A0);
Calculate the angle of rotation with inverse trigonometric functions
b = Math.asin (X/L);
Every time you perform a function, T plus 0.5 (experience)
T + + 0.5;
The pendulum is rotated, because the inverse trigonometric functions calculates the radian, so converts it to an angle
Db._rotation = B*180/math.pi;
}
};

In this way, the pendulum will definitely not move when the test, because the value of M is not defined, we have to drag in the button Layer two buttons: window-Common Library-button, select it, the button on the start of control to add code

On (Press) {
m = 1;
}

Add code to the button that controls the stop

On (Press) {
m = 0;
}

The basic composition of the original, attached source documents

Click here to download the source file

But we actually want to change the length of the pendulum. Change g, then we can make a movable button, here I do not want to wordy, directly from the library dragged one out is enough: window-common Library-button, find it yourself (I chose the Fader–round button), put them on the button layer, This button is already in the library of our source file, select it, point right-directly copy, copy out another, also drag the button layer, then we have two can be moved buttons, to change L and G, because I chose the fader–round button, it has a label, double-click the button, Enter change its label name, the result is as shown

It's not over yet, because they don't have names, check the L button, in the property bar named LK (Control L meaning), double-click the LK button, go to the next layer, look at its properties, you will find that the slider has a name, such as I chose the Fader–round button, the slider named Knob, Lk0 good for the same reason, Select the G button, named GK (Control G meaning), double-click the GK button, into the next layer, check the slider to Gk0, fast, don't forget to change your code OH

Class
a0 = 90;
t = 0;
A = 20;
m = 0;
db._rotation = 0;
This.onenterframe = function () {
The control button LK in the Lk0 button's y-coordinate +80 as a change in the pendulum length of the percentage, because the Lk0 button's y-coordinate initial value is 0, so add 80, otherwise the beginning of the pendulum long for 0
L = lk.lk0._y+80;
In the db of BX movie clips in its y direction telescopic L-fold
Db.bx._yscale = l;
Assign the length of the cycloid to H
h = db.bx._height;
The position of the pendulum is also changed, and its position should be at the cycloid registration point down + cycloid length where
db.bq._y = h+db.bx._y;
Put the control button in the Gk0 button in GK y-coordinate +9.80 as G, because the Gk0 button's y-coordinate initial value is 0, so add 9.80, so that its initial values of 9.80, otherwise start G is 0
g = gk.gk0._y/10+9.8;
The periodic formula of a simple pendulum
T = 2*math.pi*math.sqrt (l/g);
If M=1 executes
if (m = = 1) {
Vibration equation
x = A*math.cos (2*MATH.PI*T/T+A0);
Using inverse trigonometric functions to calculate the angle of rotation of displacement to X
b = Math.asin (X/L);
Time to change
T + + 0.5;
The pendulum rotates b*180/math.pi, because B is in radians and turns it into an angle system.
Db._rotation = B*180/math.pi;
}
};



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.