If Statements and Screen Wrapping

OK, the bee is flying right off the stage! Now let's get it to wrap back to the left off the stage and fly through again! We will need to have Flash keep checking to see if the bee's x position is greater than the width of the stage. You know that the bee's x position is a property described with _x, and the stage width can be found using Stage.width, so all you need is the if statement:

  1. Click Statements > Conditions/Loops > if
  2. In the Condition box type bee._x>Stage.width

If statements are also known as condtional statements (hence the "Condition" box) because they allow you to run actions only if a condition has been met. In our example, we only want flash to do "something" if the bee's x position is greater than the width of the stage. Let's define what that something is:

  1. Click Statements > Variables > set variable
  2. The Variable is bee._x
  3. The Value is 0
  4. Please do select Expression

OK, test it out:

Well, the bee doesn't ever get all the way off the stage... let's fix that next!