Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 

 
Tertiary Operator
         by ilyas usal

This operator is also used to shorten if tests. It is used in the case that: if something is true, then 1 (or 0) thing happens, otherwise 1 (or 0) thing happens. Usually, we would write it like this:

if (i<5)
{
     i++;
}
else
{
     i--;
}

The first thing we can improve concerns the brackets: when there's only 1 instruction after a if or a else, you can forget about them:

if (i<5) i++;
else i--;

The next step is to use the tertiary operator: A?B:C, which means "if A is true, then B, else C". In our previous example, it would give:

(i<5)?i++:i-- ;

If you don't want anything to happen, replace B or C by null. If you want something more complex to happen, replace B or C by a function.

 

 

 

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 Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Free Flash Page Flip
flash components Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Learn how to advertise on kirupa.com