Flash MX/ActionScript Graphics Tutorial (10)

Source: Internet
Author: User
Tags functions
Tutorial 2.3 Frame Events

2.3.1 Frame Event Profile
The main difference between frame events and the mouse events described earlier, as well as keyboard events, is that frame events are not an interactive event. Whenever the movie plays the specified frame, the code inside the frame event is executed. In the flash development environment, frame events have a "a" tag on the timeline.

In the specific design, the use of frame events is very much. For example, the 1th frame of a movie is always favored, because we usually have to do some initialization of the program in this frame, such as defining variables, functions, and so on. For example, in many interactive programs, we generally have to wait for user input (such as clicking a button), select the appropriate frame to insert a frame event, and enter a stop () or similar code in it.

2.3.2 Frame Event Application Instance
To demonstrate the principle and use of frame events, we'll make a small program that plays slides. The interface of the program has a picture display area (movie clip instance, name Picture_mc), a feedback display area (with two dynamic text, name is Message_txt and Caption_txt) and a Play Control button area (contains three buttons, The functions are playback, pausing, and resetting, respectively, PLAY_BTN, PAUSE_BTN, and rewind_btn.

The function of this program is not complicated, first PICTURE_MC will automatically switch a picture every time, the user can click the button in the play control bar below to play, pause or reset the animation.

2.3.2.1 Picture Playback
1, open the Library panel (shortcut key Ctrl+l), click on the lower left corner of the Add button to add, select the new symbol type "movie clip", enter the editing status of this movie clip.

2, add two layers, named "Picture" and "script", in the "picture" layer, add a number of blank keyframes, and then in each keyframe affixed to a picture, adjust the picture location and size, so as not to play when the picture location error.


  

3, one by one, select the frame in the "control" layer, enter code like this separately

Stop ();

_root.caption_txt.text = "Aquarius";

The first line is to let the movie clip's playback stop, that is, display the picture, and then wait for home JINGFA sent over the event to continue to play, the next statement is used in the home scene to display the content of the picture, so each frame _root.caption_txt.text= "" The contents of the back quotes inside are not the same. Note that the _root here is essential, otherwise code execution will not find the object, do not forget, we are now editing a movie clip of its own event line, and he will also quote the Boss (home view) in the object, without adding a complete title, naturally in the running time is not to find the object.






4, in the "control" layer to add more than one frame, in this frame of the time processing code input

gotoAndPlay (1)

The purpose of this code is to get the movie back to the first frame and replay it after it has finished playing.



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.