Example Name: MessageBox.fla
Language: ActionScript 1.0
Version: 1.0.0
Code:
delete_mb.setButtons(["OK","Cancel"]);
delete_mb.setMessage("Are you sure?");
delete_mb.setTitle("Delete Record");
delete_mb.setCloseHandler("myCloseHandler");
myCloseHandler = function(myMessageBox_mb, buttonIndex) {
//Get the label of the button that was pressed
var buttonLabel = myMessageBox_mb.getButtons()[buttonIndex];
//Do something based on which button was pressed
switch(buttonLabel.toLowerCase()) {
case "cancel":
trace("cancel");
//in actual practice, do nothing
return;
case "ok":
trace("ok");
//In actual practice, call the remote service
//myRemoteService.deleteRecord(recNum);
//return;
}
}
Download code text
Download chapter example files