AS3 Boolean Example


/ Published in: ActionScript 3
Save to your folder(s)

Used for the blog post: http://www.brettwidmann.com/2010/08/flash-primitive-data-types


Copy this code and paste it in your HTML
  1. //declare an int with a value of 5 and boolean
  2. var five:int = 5;
  3. var bool:Boolean;
  4.  
  5. if (five > 6)
  6. {
  7. bool = true;
  8. }
  9. else
  10. {
  11. bool = false;
  12. }
  13.  
  14. //when comparing booleans, always make sure to
  15. //use two '=' signs, otherwise you'll set the
  16. //value of the variable to what you are trying
  17. //to compare. This is called a logical operator.
  18. if (bool == true)
  19. {
  20. trace("This should actually be false. The value is 5, " +
  21. "greater than 6.")
  22. }
  23. else
  24. {
  25. trace("The value of the int is 5.");
  26. }

URL: http://www.brettwidmann.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.