Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

Flash ActionScripting for Designers: Variables, Expressions, and Functions

  • Print
  • + Share This
To write effective Flash scripts, it's helpful to understand some of the important components of the ActionScript language. Author James Gonzalez reviews three important and related ActionScript components (variables, expressions, and functions) and tells you where to get the information you need.
From the author of

As you start to modify more-complex scripts to suit your own purposes or to write your own scripts from scratch, it is helpful to understand some of the important components of the language. In this article I review several related ActionScript components: variables, expressions and functions.

Data and Variables

Most scripts beyond the very basic ones create, use, or update data during execution. A data type describes a piece of data and the kinds of operations that you can perform on it. You use many different data types when you write ActionScript. The data itself is usually stored in variables, but data types are also used in object instances and function definitions used for assigning the type of data you’re working with.

Variables are the most important and common types of data, so let’s start with them. Think of variables as uniquely named containers holding data that can be accessed anywhere in your project. Variables are created simply by naming them and assigning a value to them (referred to as "initializing the variable"), as I have done with the two variables in the first two lines of the script below. Once variables have been created and declared, they can be called up and accessed anywhere in the script simply by inserting the variable name in the script—as I do in the third line of the script below:

    var myCount:Number = 10;
    var taxpercent:Number = .06;
    var total:Number = myCount * taxpercent;
  • + Share This
  • 🔖 Save To Your Account