Chapter 4. Making Decisions ... and Repeating Yourself

In This Chapter

  • Ogling conditional statements

  • Making decisions with the if statement

  • Checking out the else clause

  • Structuring the switch statement

  • Setting up the for loop

  • Finding unknown elements with the for..in loop

  • Extracting properties with the for each..in loop

  • Iterating through a while loop

  • Getting loopy the do..while loop

Computer programs can make decisions by comparing different sets of information. In Flash CS4, this can be important for applications where more than one alternative is available to the user. Likewise, your computer can process repeated chores so that you only have to write a little code and you can repeat it using loop structures.

Making Decisions ... and Repeating Yourself

In this chapter, we explore the main applied structures of ActionScript 3.0 and also a special kind of object called an array, in which you can store all kinds of elements in a single object. You can use these structures with different functions you can create. Some of the features in this chapter may be familiar from other chapters, but in this chapter we go into more depth.

On One Condition! (Or, Maybe More than One): Conditional Statements

At its base, the conditional statement in ActionScript 3.0 works very much like everyday decisions, such as what to wear, what to read, where to go, and what to do. In all these decisions are conditions. For example, in deciding what to wear, you may ...

Get Flash CS4 All-in-One For Dummies® 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.