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

Chapter 9. Controlling Information Flow > Testing Information with Conditional ...

Testing Information with Conditional Statements

Variables and expressions go hand in hand with conditional statements. The information you retrieve, store in variables, and modify in expressions will only be useful to you when you can compare it with other pieces of information. Conditional statements let you do this kind of comparison and carry out instructions based on the results. The logic of conditional statements is like the sentence "If abc is true, then do xyz," and in Flash you define abc (the condition) and xyz (the consequence). Conditional statements are similar to event handlers in that they both respond to particular situations. In the case of event handlers, the situation is usually a movement of the mouse or a button click. In conditional statements, the situation is the current status of a variable or of a property of an object.

Conditional statements begin with the statement if (). The argument that goes between the parentheses is the condition—an expression that compares one thing with another. Is the variable myScore greater than the variable alltimeHighScore? Is the _droptarget property for my draggable movie clip unequal to the target path for the garbageCan movie clip? Does the _currentFrame property of the root Timeline equal 10? These are all typical examples of conditions. How do you construct these conditions? You use comparison operators within expressions.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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