Golden Flash guest ActionScript class record two

Source: Internet
Author: User
Tags date expression lowercase reference

The second talk look and the look

Many friends in learning as when like from the example, from the Internet down a large pile of source code, and then copy the as to the script window intact, but often do not have the effect. Even if the effect has been made, and do not know why, the next encounter similar problems can not be solved. Because we have not yet understood and mastered the basic use and meaning of the statement. Today we'll talk about how to read as statements.

I use this title to contain the double meaning, first is to look (looks), after seeing you will say "Oh, I understand" (Yes,i see!). This is not easy to achieve, and it involves a lot of programming ideas, functions, variables, expressions, and basic syntax. Unfortunately, we do not have the time and energy to explain each of the detailed usage of each statement, nor is it necessary. I want to do is also I can do is to guide everyone to learn as the method, master learning methods are often more than 100 examples more important.

We still have a simple example of the above lesson, for example, with an instance called Btn button to achieve the page jump. The statement written on the timeline is

Btn.onrelease = function () {
GetURL (http://goldflash.lpscn.com);
};

This example is simple, but though small, spite. It contains some of the basic syntax rules commonly used by ActionScript.

  First, the basic grammatical rules

  1, point Grammar

In ActionScript, Dot (.) Used to indicate the properties and methods associated with an object or movie clip. It also uses an identity to target the path to a movie clip or variable. The point syntax expression begins with the object or movie clip name, followed by a point, and finally the property, method, or variable to be specified. That means "." has two main functions: one is to locate the hierarchical structure of a movie clip, such as _ROOT.MC, or to set the properties or methods of a movie clip. So what is a property? Simply put, attributes are the characteristics of the object itself, such as name, size, location, method, and so on. such as _root.mc._x=100//Setting the horizontal axis (properties) of the MC (object) on the stage is 100 (value). Method can be viewed as the action of an object. such as _root.mc.stop ()//Set the movie clip MC (Object) Stop (method) on the stage.

  2, curly Braces

ActionScript statements are separated by braces ({}) and the statement body is written between a pair of curly braces. Here's a reminder that curly braces appear in pairs.

  3. Semicolon

The ActionScript statement ends with a semicolon (;), but if you omit the semicolon at the end of the statement, it does not affect the script's operation.

  4. Parentheses

There are two main uses of parentheses: one is to control the order in which operators are executed in an expression. parentheses override the normal order of precedence, which causes the expressions in parentheses to be evaluated first. If the parentheses are nested, the contents in the innermost brackets are evaluated first, and then the content in the outer brackets is computed.

The following statement illustrates the method of using parentheses to control the order in which expressions are executed. The value of each expression appears below each line, as follows:

Trace (2 + (3 * 4) + 5);
Show 19

The second is to enclose one or more parameters and pass them as arguments to the function outside the parentheses. SetProperty ("Star", _alpha, "30");

  5. Uppercase and lowercase letters

In ActionScript, only keywords are case-sensitive. For the rest of ActionScript, you can use uppercase or lowercase letters. If you do not use the correct capitalization when writing a keyword, your script will have an error. For example, in the previous example
Btn.onrelease = function ()
If you write
Btn.onrelease = function ()

Is wrong. When you enable the color syntax feature in the Actions panel, the keywords that are written in the correct case are displayed in blue, so it is easy to find the spelling errors of the keywords.

  6, Notes

When you select the comment action in the Actions panel, the character//is inserted into the script. If you add a comment when a user creates a script, it makes the script easy to understand:

On (release)
{
Create a new Date object
MyDate = new Date ();
Currentmonth = Mydate.getmonth ();
Converts a number of months to a text-represented month
MonthName = Calcmonth (currentmonth);
Year = Mydate.getfullyear ();
currentdate = Mydate.getdat ();
}

In the Script window, the annotation content is grayed out. They are not limited in length and do not affect the size of the exported file.

  Ii. use of Help

Learning to use Help is the most effective way to learn software. The most important thing to know about software functionality is developers themselves, and the software Help system is mostly provided by developers. Flash also offers a full set of powerful built-in help systems, with very detailed content.

You can refer to the Action Script Reference guide and the Action Script dictionary while you are learning as. For example, when you read the source code encountered a function setproperty (), and you do not know how to use the function, then you can look up the action script dictionary. Expand the action Script dictionary in the Help list box, and then expand the list of keywords that begin with the letter S, and you can see the function, and the right window lists the specific usage of the function when the function is selected.

There is also a more concise approach, such as you have entered the function into the Script window, you can directly select the function,

Then click the Script Reference button in the upper-right corner of the script window to open the Help panel directly.

Knowing some of the basic syntax of AS and learning how to use Help, you will find that learning as is not difficult.



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.