davidpadua
12/3/2013 - 1:02 AM

Ternary operation

Ternary operation

Using the Ternary Operator in ActionScript 3.0


A possible and typical solution to this would be as follows:

if(displayBox == true) {
box_mc.visible = true;
} else {
box_mc.visible = false;
}

>>>>>>>>>>>>

(condition) ? true result : false result;

/////////////////////////////////////////////////

var memberType:String;

if(isAdministrator == true) {
memberType="admin";
} else {
memberType="subscriber";
}

>>>>>>>>>>>>>>>

var memberType:String = isAdministrator ? "admin" : "subscriber";