Boolean Data Type


Boolean Data Type

The next data type we'll discuss is Boolean. Boolean data types are logical answers in the form of TRue or false. Also notice that these words cannot be used as variable names or identifiers in ActionScript because they are strictly Boolean data types. Let's take a look at a use of Boolean:

 var alarm:Boolean = true; if (alarm == true) {       trace ("Wake me up!"); }else{       trace ("Let me sleep in."); } // output: Wake me up! 

Because alarm is set to TRue, the if statement evaluates to TRue and traces the appropriate message. If the alarm had been set to false, the else statement would have taken effect.

Also note, Boolean values can be written numerically as well. The number zero represents false, and all nonzero numbers, including negative numbers, are true like the following examples.

 trace(Boolean(0));      //false trace(Boolean(1));      //true trace(Boolean(-1));     //true 




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net