Easy to build flash frame rate Tester

Source: Internet
Author: User
Tags reset

Flash works in the preset frame rate is only idealized, but the reality is that flash processing programs or rendering the image needs to consume a certain amount of time, so the animation run at the frame rate of each frame is basically different. Put too many symbols in a frame, the frame rate will be much lower than the preset frame rate, causing the screen playback is not smooth, or out of frame. If you use the frame rate tester to detect your animations, you can see the above problem. Because the frame rate tester works, it displays the current average frame rate of the movie. In short, whether the design of the game or the production of large animation, slow, unstable work is not attractive, no one can endure a only 4 frames/second animation.

Effect preview:

Figure 1

Design points:

First the tester itself should be as simple as possible, otherwise it will affect the test results. The main tester is a dynamic text and a reset button for outputting test results. The reset button is used to get an accurate frame rate, and the way it works is to refresh the tester. When the tester tests itself, the frame rate shown should be the same as the preset value.

Design steps:

1. Open Flash MX, set the scene size to 350pxx100px, background color is "#0E6A99" (in fact, the setting of the scene is irrelevant). Press the shortcut key "Ctrl+f8" to create a new movie clip symbol named "fps."

2. Click the Text tool in the Select tool panel in the scene of the symbol "FPS"


, and then create a static text and enter a "frame rate:" A few words, as shown in Figure 1. Then create a dynamic text box, click to select the dynamic text box, and make the settings shown in Figure 2 in its property panel. The most critical setting is that you must define the variable "out."

Figure 2

3. Press the shortcut key "Ctrl+f8" to create a new button symbol named "button" (The design of buttons should be as simple as possible). Enter the "reset" two word on the button, as shown in Figure 1.

4. Right click on the button, click the pop-up menu "action" command, in the Actions panel, enter the following code:

Release event is releasing the mouse button when the mouse pointer passes over a button

On (release) {

The function of a variable frame is to record the current number of frames

frame = 0;

function Gettimer () can return the time the movie has played, in milliseconds

n = Gettimer ();

}

5. Back to the main scene. Press the shortcut key "Ctrl+l" to open the library and drag the movie clip symbol "FPS" from the library to the main scene.

6. Right-click the movie clip "FPS", click the pop-up menu "action" command, and in the Actions panel, enter the following code:

Onclipevent is an "event" trigger. When an event occurs, the statement in curly braces is executed.

The Load event is the execution of a statement when a movie clip is loaded.

Onclipevent (load) {

frame = 1;

n = 0;

}

The Enterframe event executes a statement every time the movie executes a frame

Onclipevent (enterframe) {

Variable time is used to record

Time = (Gettimer ()-N)/1000;

The Ceil method of the Math object can return an integer greater than or equal to the value in parentheses and its closest

The current frame rate is the frame divided by the time of play

out = Math.ceil (frame/time);

Variable frame (frame number) to accumulate

frame++;

}

Here, the frame rate tester is designed. Now just copy and paste it directly into the animation you want to test to use. Note that when you use a tester, it's a good idea to create a new layer in the scene where the animation is being tested, and then copy and paste the tester into the layer, which makes it easy to adjust the position of the tester and modify and clear it.

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.