Syntax and Language Fundamentals

Learning ActionScript syntax and statements is like learning how to put together words to make sentences, which you can then put together into paragraphs. ActionScript can be as simple. For example, in English, a period ends a sentence; in ActionScript, a semicolon ends a statement. In the ActionScript language, you can type a stop() action to stop the playhead of a movie clip instance or a SWF file from looping. Or you can write thousands of lines of code to power an interactive banking application. As you can see, ActionScript can do very simple or very complex things.

In Data and Data Types you learned how the ActionScript language uses data, and how you can format it in your code. This chapter demonstrates how you can form statements in ActionScript using syntax. It contains many short code snippets and some examples to demonstrate fundamental language concepts. Upcoming chapters contain longer and increasingly involved code examples that combine and facilitate the fundamentals you learn in this chapter.

The general rules described in this section apply to all ActionScript. Most ActionScript terms also have individual requirements; for the rules for a specific term, see its entry in the ActionScript 2.0 Language Reference.

Applying the basics of ActionScript in a way that creates elegant programs can be a challenge for users who are new to ActionScript. For more information on how to apply the rules described in this section, see Best Practices and Coding Conventions for ActionScript 2.0.

NOTE

 

You add ActionScript directly to a frame on the Timeline within this chapter. In later chapters, you use classes to separate your ActionScript from the FLA file.

For more information on working with ActionScript syntax and language fundamentals, see the following topics:

About syntax, statements, and expressions
About dot syntax and target paths
About language punctuators
About constants and keywords
About statements
About arrays
About operators

Flash CS3