The writing method of Flash script and the use of basic script

Source: Internet
Author: User
Script one, about how to write the script in Flash
First, you need to know that scripting doesn't require users to have a complete understanding of as!
The question to consider now is how to add a script to your flash? Simply put, there are two ways to add a script: one is to write the script on the key frame above the timeline (note that you must be a keyframe to add a script). The second is to write the script on the object, such as writing the script directly on the MC (the movie clip symbol instance) on the top of the button.
In addition, you need to have a simple understanding of how flash is executing your script. When you add a script to a keyframe on a time week, when Flash runs, it first executes the script on the keyframe before it shows the object on the keyframe.
And some simple knowledge, what do the objects in as include? It can contain data, or it can be a movie clip on the stage, or it can be a button on the stage. Since it contains so many objects, each object must have its own attributes! For example, the movie clip (MovieClip) object, its properties are: _height (height), _rotation (rotation), and so on, these properties do not need you to deliberately memory, when used when you can flip through the script dictionary. In the future tutorial will be to introduce some of the basic scripting skills.
Cut the crap and start this tutorial example:

   Second, the teaching needs to learn the basic as command as follows:
Stop (), play (), gotoAndPlay (), gotoAndStop (), NextFrame (), Prevframe (), Nextscene (), Prevscene ();, Stopallsounds (); The as write rule for the button.

   Iii. Case-making
To get a clearer idea of these simple commands, let's start with a simple example!
First, take a look at the example, simply control the movie playback, pause, forward, back, stop
   Click to download source files
Final Effect Demo
1, open flash, press CTRL+F8, create a new movie clip, and start with the name Mo. You need to do a simple motion animation movie clip first. Just do a round rolling effect.

2. Back to the stage workspace, press F11 to open the library, drag mo movie clips onto the stage. And give this instance a name called MC. (Now you can press CTRL + ENTER to test the effect, you can see that the circle has been moving continuously.) )
3, add script, now let this MC at the beginning of the film do not play automatically, otherwise how to control it. Let's write the script on the key frame of the timeline. Select the first frame of the timeline, press F9 to open the Action panel, select the Expert mode, enter: _root.mc.stop (); (_root represents the stage, the script means that the instance of the name MC on the stage stops playing.) )

4, now we make a few buttons, respectively, to play, pause, forward, back, stop. and placed on the stage. I do not introduce the method of making the button more.
5, now to add a script to control the movie. This time write the script directly on the stage of these buttons on the body. Select the Play button, open the Action panel, and enter:
On (release) {
_root.mc.play ();
}
If you want to write a script on the button, you must write it using the format of On (event) {//scripting}! The above script is: When you click on the button on the mouse (release event), you will execute the following _root.mc.play (), the program, it means that the stage of the MC to start playing!
6. The same: Let's Select the Pause button on the stage and enter it on it:
On (release) {
_root.mc.stop ()
}
Then, in turn, on the back, enter:
On (release) {
_root.mc.prevframe (); Prevframe back to the previous frame of the animation
}
On the Fast Forward button, enter:
On (release) {
_root.mc.nextframe ();
}
On the Stop button, enter:
On (release) {
_root.mc.gotoandstop (1); Jump to the first frame of the MC movie and stop playing!
}
All right, so far, it's over, you can press CTRL + ENTER to test your results.

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.