Make Flash mouse following effect (figure)

Source: Internet
Author: User
Tags square root

1. Sets the size of the scene to be 400pxx30px, the background color is #00659c, and the frame rate is 12fps.

2. Press the shortcut key Ctrl+f8 Open the Create new symbol panel creates a new graphic symbol named "Grimace." Then use the "oval" tool to draw a mouth-watering grimace and make two small holes for your eyes. The method is also very simple, using the "ellipse" tool to draw a circle, and then use the Arrow tool to remove the small circle inside. As shown in Figure 2

Figure 2

3. Make pupil. Creates a new movie clip symbol named "Pupil". As shown in Figure 3, draw a dark gray circle in the scene of the pupil element, a black circle, and a few small white circles.

Figure 3

4. Make eyes. Create a new movie clip symbol named eyes. Use the Ellipse tool to draw a color-#999999 circle in the scene first. Open the Library, drag the "pupil" movie clip to the scene and place it on a gray circle. Note: The center of the pupil element overlaps the center of the scene. As shown in Figure 4.

Figure 4

5. Click the pupil component, and then give it an instance name "Eye" in the Properties panel. As shown in Figure 5. (www.3lian.com)

Figure 5

6. Click the 2nd frame in the eye component scene and press F6 to insert the keyframe (if you turn the gray part of the 2nd frame into a bright color such as yellow, you can also see the effect of the eyes). Right-click Frame 1th, select the action command from the pop-up menu, and then type the following code:

Property _xmouse and property _xmouse are used to get the coordinates of the mouse in the x-axis and y-axis directions

Property _x and property _x to get or set the coordinate values of the movie clip symbol in the x and y axes of the scene

The data that the variable I accepts is the line distance from the scene origin to the mouse

i = math.sqrt (_xmouse*_xmouse+_ymouse* _ymouse);
eye._x = 25/i*_xmouse;
eye._y = 25/i*_ymouse;


The code uses the Math object Math method sqrt (), and its function is to compute the square root of the number. The number "25" in the code is the size of the "pupil" component in the home scene, so the main purpose is to not allow the pupil to fly outside the eye.

7. Press the shortcut key Ctrl+f8 Open the Create new symbol panel creates a new movie clip symbol named Banana. Then press the shortcut key ctrl+r to open the import panel and find a "banana" material import, as shown in effect figure 1.

8. Back to the main scene. Drag the graphic symbol "grimace" from the library to the main scene. Then drag the "eye" movie clip element from the library to the main scene and copy an eye. The two "eye" elements are then placed in the sockets, as shown in Fig. 1.

9. Drag the banana movie clip symbol from the library to the main scene, click the banana symbol, and give it an instance name "Banana" in the Properties panel. Then right-click the banana and type the following code:

Onclipevent (MouseMove) {
Mouse.hide ();
StartDrag ("_root.banana", true);
}

Onclipevent () is an event trigger, which has been passed before, and the event MouseMove triggers the event when the mouse moves, executing the code in "{}". _root is a reference that specifies or returns a movie in the main scene. If the movie has multiple levels, the root movie timeline is at the level that contains the currently executing script. For example, if the script in Level 1 calculates _root, the _level1 is returned. Mouse Object Mouse Method Hide () hides the mouse in the scene. The feature of the movie clip control statement StartDrag is that you can drag a movie clip from the scene.

The effect completes the final effect as shown earlier. Now reader friend can press shortcut key "Ctrl+enter" test, I believe you do that eyes more God. In short, mastered this effect, that is, master the basic use of the mouse method.

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.