How to Implement If/Then Logic In Macromedia Flash 3
By J. Scott Hamlin
Blessing and curse. That's how one could describe Macromedia Flash's lack of internal scripting support. Many Web designers have embraced Flash's relatively user-friendly development environment ("user-friendly" at least in comparison with Macromedia Director) in part because of the absence of an intimidating scripting language. On the other hand, if you want to push the envelope, the lack of an internal programming capability in Flash becomes a substantial liability.
If you've been following the product, you know that version 3 added features that made it easier to control Flash movies with external scripting languages like JavaScript. Unfortunately, the types of functionality that you can implement with Flash 3 internally are still very limited -- but are sufficient. Two new features in Flash 3, Movie Clips and Tell Target, provide the basic tools to implement a crude form of if/then logic within Flash. That is, with Movie Clips and Tell Target you can make something happen after a certain number of key events take place. Another way of putting it is: If events A and B occur, then event C will be initiated. This sort of if/then logic can be the basis for simple applications that you might wish to use on any Flash applications on your Web site. For this example, we'll use the if/then logic to implement a classic "concentration" or memory game. (The game is available online as an executable file; see "Source-Code Availability" on page 3.)
Mix and Match, If and Then
In the classic, physical concentration game, several pairs of matching playing cards are arranged face-down on a table.