Chapter 2. Understanding ActionScript 3.0 Language Basics


In this chapter

  • Defining variables and constants

  • Applying operators and functions

  • Assigning core data types

  • Working with scope

  • Using techniques to effectively comment your code

So you want to be an ActionScript coder? Great! This chapter will get you started with the basic syntax and structure of the language. If you have worked with other programming languages, some of the topics covered will be familiar territory for you. However, even if you are an experienced ActionScript 2.0 user, you will find a few subtle differences in this version of ActionScript so we recommend that you read through.

Using Variables

Back in high school, I used to argue with my algebra teacher that the subject matter would never be useful in the real world. Even though I have yet to simplify a polynomial outside of the classroom, I have to admit I was wrong. ActionScript 3.0 is built entirely around the use of variables just like the x and y variables in an algebra problem.

A variable is a representation of a number, string of characters, or some other value that can change values the way the x variable in algebra represents a number that may have any value. You might think of variables as containers used to hold pieces of information. In ActionScript, variables contain chunks of information known as objects for the time during which your program is running. They allow your program to temporarily hold on to that information and behave differently ...

Get ActionScript™ 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.