Tuesday, August 28, 2007

Conditions

Conditions in AS3 are exactly the same as they were previously (woo hoo!) All the operators are the same, you can nest conditions, you can have compound condtions and so forth. Here is an example of one:

check_mc.addEventListener(MouseEvent.CLICK, onClick); //add mouse event, call onClick function

function onClick(event:MouseEvent):void{ //define onClick function
if(box1_mc.rotation == box2_mc.rotation || box1_mc.alpha == box2_mc.alpha){ //if rotation is the same OR alpha is the same..
trace("condition is true");
}else{ //if not...
trace("condition is false");
}
}

check_mc.buttonMode = true; //set check_mc as a button/show hand cursor

No comments: