Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS



ASP.net / PHP






  Design & Effects
  Audio & Video
  User Interface





Simple If/Else Tests
         by ilyas usal

There's a very useful shortcut in if...else tests when you test whether a variable equals 0 or not. But you have to know how to use the ! operator. This operator is used to invert a boolean.
What does that mean? It means that if you have:

myBool = true;
trace (!myBool);
// returns false

It is also used to test the inequality between two numbers, objects... Remember that in Flash, 0 is equivalent to false, and any other number is considered as true.

myValue = 5;
if (myValue != 0)
     trace ("myValue is not 0");
// returns myValue us not 0

Now to test whether a number is or isn't equal to 0, instead of doing:

if (myValue == 0) //...
if (myValue != 0) //...

You can do respectively:

if (!myValue) //...
if (myValue) //...

Imagine that myValue = 0. !myValue will be evaluated as true. The same way if myValue = 5, !myValue will be evaluated as false.

Hope this tutorial helped. If you have any questions, please post them on the forums at http://www.kirupa.com/forum/


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
flash components Free Website | Make a Website
Streamsolutions Content Delivery Networks Learn how to advertise on kirupa.com