Flash MX 2004 Programming (AS2.0) tutorial (i)

Source: Internet
Author: User
Tags comments key key words
Programming | Tutorials

Introduction to the 1th Chapter

ActionScript is a programming language that is dedicated to flash. ActionScript's syntax is similar to JavaScript or Java, and if you've ever contacted both languages before, you'll find ActionScript very easy to use. Even if you don't have access to Java or JavaScript, mastering and using ActionScript is no big feat.

The evolution process of 1.1ActionScript

ActionScript is constantly evolving, the earliest appeared in Flash 5, the latest version is ActionScript 2.0, has become mature. The ActionScript in Flash 5 runs very slowly and has a poor flexibility to implement object-oriented programming. In Flash MX, ActionScript solves some of the previous problems while improving performance and development patterns. The Flash MX 2004 has again made overall improvements to ActionScript, and the 2.0 edition turned out to be a truly professional-level programming language.

Composition of the 1.2ActionScript program

Like all programming languages, ActionScript has its own "elements", such as keywords, grammatical formats, and so on, to learn about these basics is one of the most basic steps to learn flash.

Let's look at the structure of the ActionScript program with a brief snippet of code that defines the behavior of a button, and now we don't need to delve into what this code is for, just dissect it and understand its structure.

On (release) {

var angle:number = 5.00;

wheel_mc._rotation=90;

Wheel_mc.gotoandplay (50);

}

Event

Events, in programming, are similar in meaning to what he means in everyday life. For example, if you move the mouse in a Flash movie, click the mouse, and press a key on the keyboard to create an event. In the example above, release is an event that occurs when the user releases the mouse on the current button, and the code in the curly braces behind on (released) is used to handle the event.

Statement

Each complete statement in ActionScript is separated by a semicolon ";" End, perform a specific action, such as this code var angle:number = 5.00;

He will create a variable named angle with a numeric type and set its argument to 5.0.

Another example is Wheel_mc.gotoandplay (50), which is the function of playing the movie from the 50th frame of the movie clip Wheel_mc.

Operator

Operators are very well understood, and the meanings are essentially the same as those for mathematical and logical operations, including =,,, + 、-、 *, and so on.

Key words

The key word is the "private property" of ActionScript, when designing, it must be "taboo" when the user-defined elements such as variables and functions are named. For example, on is a keyword, then we can't name the variable on, otherwise the program will be confused by you, don't know what you want it to do.

Point (.)

This little dot (".") It is easy for beginners to feel the brain, although it is inconspicuous, with very frequent, its role is usually two. First, it can be used to locate a movie clip, such as _ Root.china.cities.beijing This statement represents the movie clip named Beijing in the movie clip named "Cities" on the main event line, which is rather awkward, but if we practice this little spot as "middle", The problem is clear.

ActionScript is an object-oriented design language, so there is another use for this point is accessing object properties, calling Object methods. For example, we want the movie clip wheel_nc to rotate 90 degrees, and you can use such a statement (where _rotaion is a property of the movie clip): Wheel_mc._rotation = 90;

For example, if you want to play a movie clip from ActionScript, you can use

Wheel_mc.play ().

Comments

The annotations in ActionScript and the details in many languages are only for developers to make notes and not as a formal part of the program. Multiple lines of comments start with//, multiline comments start with/*, End with/*







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.