Step by step by step ActionScript 2.0 (7)

xiaoxiao2021-03-06  45

Tutorial source:

http://jinjunshi.blogchina.com

Button Emotional "Event" [Learning Objectives]: Understanding the Concept of Event, Actions, Objects, and Functions. The specific corresponding operational behavior of the true corresponding to the eight events on the button. These two days are relatively busy, have not come and write tutorials, review the tutorial six, we learned the most basic thing: "Take the name." The official language "Identifier" = the name. Now let's let the script are placed there, then how is the script work, just how to run, run your script, it is necessary to trigger, soby, you do a variety of gift flowers. No time to ignite, you can't see it. The as needed is "event", let's take a look at the "event" focused on the button.

"Software or hardware happening" in AS is called an event. Suppose we use flash to make an MP3 player, which must have a "click the play button to start singing a song" action. In the operation, "click" is an event. This "event" triggers the "action" of playing the specific song, where the button, song is all "objects" we control, complete this operation, on the button Use a "function" ON (). Adding two joints we have contacted a lot of concepts, everyone may be confused, there is nothing, slowly understand. 1 "Event": what happened. It can be inside the system, which can be its own. For example, I write the tutorial, "there is no smoke", it is an event. 2 "Action": The action is to indicate the SWF file to execute some tasks when playing the SWF file. For example, gotoAndStop () places the playhead to a specific frame or tag. Is a statement, not. For example, I don't have smoke, "I call my son to go to the street to buy bag", it is the action. 3 "Object": It is what you want to do. The button is an object. But it is abstract. For example, "I", "smoke", "son" is an object. 4 "instance": the specific object. For example, "people" is an object. "Zhang San" is an example of "people". 5 "Function": Collengerate a command to complete a specific action. For example, the ON () function. Some concepts are here to know, we will tell us in the future. As can be seen from the above knowledge, "Events" is especially important, there is "event" to generate "action", and our script has no white-write. In AS, we know that three places plus AS, which is of course eventual production in this three places. Below we will watch the "events" on the button, they are done through the function. ON (mouseevent) {

// Here is your statement

} The mouseevent called the parameters here is the prerequisites. The specific is our "eight events": 1. Press: a simple mouse click event can be divided into two processes: mouse press (press) and mouse release (Release). When the mouse moves to a button-clicking area and tap the button, the Press event occurs, which is suitable for the occasion of the button as a switch. 2, Release: Release the mouse button when the mouse pointer is passed through the button. 3, Releaseoutside: When the mouse pointer presses the button, move the mouse pointer to the button, release the mouse button. 4, the Rollover mouse pointer slipped the button. 5, ROLLOUT Mouse Pointer Solids the button area 6, Dragover Press the mouse button while sliding the button, then sliding out this button, then sliding back this button. This is a very useful event that can be used in many occasions, such as games, and shopping carts. 7, Dragout Press the mouse button when the mouse pointer slipped through the button, then slipped out this button area. 8, KeyPress ("Key") Press the key specified on the keyboard. This special, not the mouse is the keyboard :), let's introduce it again. Below we are a Flash good experience, the incident on the top 7 mice. [Requirements]: Show the current event introduction by different events on the button. [Steps]: 1, create a new Flash document. 2, drag from the button library out 7 you like the button in the newly created 7 layers. 3, new layer, put a dynamic text above, the variable corresponds: mouse_txt. 4, the layout looks into the picture below. 5. Add AS separately on each button. Format Similar: on (mouseevent) {mouse_txt = "Contents of specific introduction";

} Pay attention to the mouseevent of each button corresponding to different events. You can download the source code to take a closer look, the main purpose is to use the mouse to practice, truly master, and when needed to correspond to various events.

转载请注明原文地址:https://www.9cbs.com/read-72778.html

New Post(0)