• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Controlling Information Flow > Initializing Information

Initializing Information

Variables hold information. You can create, change the contents of, and discard variables at any time. The first time you put information into a variable is called initialization. Initializing and changing a variable involves the set variable action. You've initialized variables before; we just didn't call it that. When you create new objects using set variable, as in the statement myColor = new Color (myMovieClip), you initialize the variable myColor. In this case, the variable contains the color object, but a variable can hold any kind of information, such as a number, letters, a true or false value, or even a reference to another variable. The different kinds of information that variables can contain are known as data types.

Variables and Data Types

Examples of typical types of variables are a user's score (number data type), an Internet address (string data type), a sound object (object data type), and the on/off state of a radio button (Boolean data type). You can easily change the data type that a variable holds. A variable that was initialized with a number data type can be changed later on in the movie to hold a string data type with a new set variable action. However, it's a good practice to keep the data type of variables constant so that when you manipulate them, you don't get unexpected results (for example, trying to multiply a string by a string). The different data types that variables can hold are listed in Table 9.1.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint