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

Chapter 5. Programming Structures > Conditional and Loop Statements

Conditional and Loop Statements

Flash executes every line of script that it encounters. If a script is never encountered, it’s never executed. And, if a script is encountered repeatedly, it is executed over and over. Using conditional statements, you can control what part of your script is executed or skipped. Obviously, if you place a script on a button and the user never clicks the button, the script won’t execute. However, after a button is clicked, a conditional statement can control what portion of the contained script executes. This way, you can write scripts that behave differently depending on outside conditions.

Looping is a way to make a particular script execute repeatedly—either a certain number of times or until a condition is met. This is helpful when you have a lot of code to process, but also when you’re not sure how many times the code needs to execute. In the upcoming section on loops, you’ll find that loops can save you a lot of typing. Compare the following two pseudo-code descriptions in which a loop would help:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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