The interactive function of a button in Flash is usually done by a button. Mastering the Rules of button writing is also a basic skill of a flash.
OK, now let's talk about how the button script is written. As mentioned in the previous lecture, as script writing can be written on the key frame of the timeline or on the object itself. button is no exception, can be written on the timeline, can also be written on the button itself. But these two kinds of writing rules must follow certain rules, this is something.
Now let's do an example, make a button, this button to achieve the function is to open a specified Web page. (This example is very basic, using this example to explain the button as two writing methods.) )
Here is the final effect demo: ( Click here to download the source file)
The first: Write the script in the button itself.
Draw a rectangle on the stage, select the rectangle and press F8 to convert the rectangle to a button symbol.
Second, write the action script:
Select the button, press F9, open the Action panel, and enter the following script in Expert mode:
On (release) {
GetURL ("http://bbs.graphicvale.com/", "_blank")
}
This button now implements a function of opening a Web page. You should note, by example, that the as writing rules for buttons are:
On (event) {
To execute the script, just the example is using Geturl to open a Web page. You can also use a scripting program to perform other functions, such as jumping to a frame, or loading an external animation file.
}
As you can see, there is actually an on statement, and this on statement is the button's as write rule. What you need to be aware of is the event on, which you can interpret as the action of the mouse or keyboard. The example we used just now is release (click the mouse) I'm going to list the usual button events:
Event name Description
Press event occurs when the mouse is over the button and the mouse is pressed
Release occurs when a mouse is pressed over the button, and then the mouse is released. That is, "click" The Mouse
Releaseoutside occurs when you press the mouse over the button, then move the cursor outside the button, and then release the mouse
Rollover when the mouse is sliding into the button
Rollout when the mouse is sliding out of the button
Dragover occurs when you press the mouse, the cursor slides into the button
Dragout occurs when the mouse is pressed, the cursor slips out of the button
Keypress occurs when a user presses a specific keyboard key
Let's look at how the second type of button as is written.
This approach is to write the script on the timeline, not the button itself.
One, select the button, in the following property panel for the button name, here I played a BT
Second, select the first frame of the timeline, press F9 to open the action panel. Enter the following script:
Bt.onrelease = function () {
GetURL ("http://bbs.graphicvale.com/", "_blank");
};
The rule to be followed for this method of writing as is the following formula:
The name of the button instance. Event name =function () {
The script program to execute.
}
Just remember this formula and you can apply it.
The As of the button will be here first, this is a basic skill. I hope we all can master it.
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