Frame 1
function update(state, opponentName) {
trace2("in challengeMsg, update, state = " + state);
if (state == _root.ChallengeState.REQUEST_SENT_AND_WAIT) {
txtTitle.text = _root.ltxt("WAITING_FOR_OPPONENT");
txtTitle2.text = _root.ltxt("WAITING_FOR_OPPONENT");
txtMessage.text = _root.ltxt("ALERT_WAITING_FOR_MEMBER_TO_ACC");
icons.gotoAndStop(3);
btnOK._visible = true;
btnOK.setLabel("BTN_CANCEL");
btnOK.onPress = function () {
hide();
_root.cancelChallenge();
};
gotoAndPlay (3);
} else if (state == _root.ChallengeState.REQUEST_REJECTED) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtMessage.text = _root.ltxt("ALERT_MEMBER_HAS_DEC_CHALLENGE");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.OPP_NOTOKEN) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtMessage.text = _root.ltxt("ALERT_MEMBER_HAS_DEC_CHALLENGE");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.OPP_DIFF_VER) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_DECLINED");
txtMessage.text = _root.ltxt("ALERT_MATCHUP_MISSMATCH");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.REQUEST_NOT_DELIVERED) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtMessage.text = _root.ltxt("ALERT_CHALLENGE_NOT_DELIVERED");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.REQUEST_ACCEPTED) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_ACCEPTED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_ACCEPTED");
txtMessage.text = _root.ltxt("ALERT_MEMBER_HAS_ACC_CHALLENGE");
icons.gotoAndStop(2);
btnOK._visible = false;
btnOK.onPress = function () {
};
} else if (state == _root.ChallengeState.REQUEST_CANCELED) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_CANCELED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_CANCELED");
txtMessage.text = ((_root.ltxt("CHALLENGER:") + opponentName) + newline) + _root.ltxt("CHALLENGE_CANCELED");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.REQUEST_TIMEOUT) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtMessage.text = _root.ltxt("ALERT_COMMUNICATION_FAILED");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
} else if (state == _root.ChallengeState.REQUEST_OPP_OFFLINE) {
txtTitle.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtTitle2.text = _root.ltxt("UC_CHALLENGE_NOT_DELIVERED");
txtMessage.text = _root.ltxt("BL_MSG_OFFLINE_NOW");
icons.gotoAndStop(2);
btnOK._visible = true;
btnOK.setLabel("BTN_OK");
btnOK.onPress = function () {
hide();
};
}
}
function hide() {
this._visible = false;
}
function show() {
this._visible = true;
}
function initMain() {
txtTitle.setFont(tfN10);
txtTitle2.setFont(tfN10);
txtMessage.setFont(tfN2);
txtTitle.text = "";
txtTitle2.text = "";
txtMessage.text = "";
btnOK.setLabel("");
}
var seconds = 30;
var endTime = 0;
this.tabEnabled = false;
this.tabChildren = false;
nextFrame();
Instance of Symbol 13 Imported [easoButtonS] "btnOK" in Frame 1
//component parameters
onClipEvent (initialize) {
label = "BTN_OK";
bLocalize = true;
bcolor = "blue";
}
Frame 2
initMain();
stop();
_parent.challengeMsgOnLoad();
Frame 3
endTime = getTimer() + (seconds * 1000);
Frame 5
stop();
if (getTimer() < endtime) {
if (_root.gChallenge.state == _root.ChallengeState.REQUEST_SENT_AND_WAIT) {
gotoAndPlay (4);
}
} else if (_root.gChallenge.state == _root.ChallengeState.REQUEST_SENT_AND_WAIT) {
_root.processChallengeMessage(_root.gChallenge.opponentName, _root.ChallengeMessageType.IS_BUSY, "");
}