Ever had a bit of actionscript code that you didn’t understand, or wish you new more about. Well, I’m going to start explaining bits of AS2 code in my next few posts. The code posts will be spread out between my normal posts, so you’ll know if it is a a bit of code when you see the title. Let’s get started.

The if statement is one of the most useful statements in AS2 coding. You can use it to check just about anything. It’s a fairly easy bit of code to pick up too. It’s sort of like a logical question. Here is an example:

if(iWin==true){//if the variable iWin is true then...
gotoAndStop('winScreen');//go to the frame labeled winScreen and stop on that frame.
}//end code

The // symbol means that whatever comes after it is a comment. So just read the comments to learn how it works.

The if statement could be used to make whole games when you combine it with variables. Learn how to use it, and you are well on your way to becoming a better coder.

Related posts:

  1. Code Bits: Timeline
  2. Code Bits: Variables
  3. Code Bits: hitTest