Throughout this book we use statement blocks (statements surrounded by curly braces) with all conditional statements, even if a block contains only one statement: if (x = = y) { trace("x and y are equal"); } For the sake of brevity, ActionScript does not require curly braces when a conditional has only one substatement. A single substatement can, quite legitimately, be placed directly after an if or else if statement without any curly braces, like this: if (x = = y) trace ("x and y are equal"); or even on the next line, like this: if (x = = y) trace ("x and y are equal"); For some programmers, this style can be a little slower to read and slightly more error-prone, though it undeniably saves room in source code. |