Demonstrate uniform acceleration linear motion with Flash MX

Source: Internet
Author: User
Tags set time time interval

Create Symol (symbol)

Create the following several symol (symbols) by using the menu "insert→new symol" command:

1, a movie Clip (movie clip), named "Dolly", draw a rectangle, representing the car.

2, three button (buttons), made into a rectangle or a circle, respectively, for Play (start), Stop (stop), restart (return).

Program specific production

1, into the scene (scene), the current layer Layer1 named "Car", from the library dragged into the production of a good car movie Clip, placed to the appropriate location, and movie Clip the car's "Instance name" named "Dolly" : Select the trolley and enter "Dolly" in the "Instance Name" field in the properties panel below.

Enter the actions statement at the first keyframe of the trolley layer:

Stop ();

S0=getproperty ("/dolly", _x)//Set Dolly horizontal Orientation initial Position property

t = 0;

A = 2; Set Acceleration to 2

x = 0;

v = 0;

Insert a keyframe (key frame) in the second frame of the trolley layer, keep the car position unchanged, and enter the actions statement:

t = t+0.5; Set time interval

s = s0+0.5*a*t*t;

x = S-s0;

v = a*t;

SetProperty ("/dolly", _x,s)//Set function properties

2, new layer Layer2, named "Main interface", in the edit area, enter the words "uniformly accelerated linear motion" and enter the text "S=m, A=m/s2, v=m/s, T=s", and insert a text box between "s=" and "M": Select the text Input tool in the toolbar, "s=" in the edit area Click between "M", insert an input text box, resize, in the properties panel below, the Text property selects input text, selects the Show Borders button, enters "X" in the Var field, and names the text box "X", as shown in Figure 1.

Figure 1

The same method inserts a text box between "a=" and "M/s2", "v=" and "M", and "t=" and "s" respectively, and is named "a", "V", and "T" respectively.

Draw a line indicating the scale, the plane of the car movement, drag from the library play, Stop, restart three buttons, adjust the position between the parts, as shown in Figure 2. Enter the actions statement individually in the three buttons:

Figure 2

(1) Play button

On (release) {

Play ();


(2) Stop button

On (rollover) {

Stop ();


(3) Restart button

On (release) {

gotoAndPlay (1);




SetProperty ("/dolly", _X,S0);


3, new layer Layer3, named "Motion", in the third frame of the motion layer insert a keyframe, enter the actions statement:

gotoAndPlay (2)//After playing the third keyframe and starting from the second Keyframe

Finally made the program interface as shown in Figure 2, press the "Ctrl+enter" test, the effect is good! If you feel a bit slow, modify the acceleration.

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: 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.