Show new messages immediately; optional callback when message disappears

This commit is contained in:
Jeremy Penner 2011-02-04 09:13:15 -08:00
parent 5599a8784d
commit 86e300ba7d

View file

@ -290,14 +290,19 @@ package
super.update(); super.update();
} }
private var dgOnMsgDone: Function;
// message management // message management
public function ShowMsg(stMsg: String):void public function ShowMsg(stMsg: String, dgOnMsgDone:Function = null):void
{ {
rgmsg.push(stMsg); KillSidebarMsg();
if (alarmMsg === null) this.dgOnMsgDone = dgOnMsgDone;
ShowNextMsg(); var x:int = FP.width / 8;
sidebarMsg = Sidebar(add(new Sidebar(x, x, FP.height - 45, FP.height, x * 6, 45, LAYER_MSG, false, false)));
new TextSidebar(sidebarMsg, stMsg, 2);
sidebarMsg.Toggle();
alarmMsg = Alarm(addTween(new Alarm(2, function():void { sidebarMsg.Toggle(KillSidebarMsg); }, Tween.ONESHOT), true));
} }
private function ShowNextMsg(): void private function KillSidebarMsg(): void
{ {
if (sidebarMsg !== null) if (sidebarMsg !== null)
{ {
@ -307,16 +312,9 @@ package
if (alarmMsg !== null && alarmMsg.active) if (alarmMsg !== null && alarmMsg.active)
removeTween(alarmMsg); removeTween(alarmMsg);
alarmMsg = null; alarmMsg = null;
if (dgOnMsgDone !== null)
if (rgmsg.length > 0) dgOnMsgDone();
{ dgOnMsgDone = null;
var stMsg:String = rgmsg.shift();
var x:int = FP.width / 8;
sidebarMsg = Sidebar(add(new Sidebar(x, x, FP.height - 45, FP.height, x * 6, 45, LAYER_MSG, false, false)));
new TextSidebar(sidebarMsg, stMsg, 2);
sidebarMsg.Toggle();
alarmMsg = Alarm(addTween(new Alarm(2, function():void { sidebarMsg.Toggle(ShowNextMsg); }, Tween.ONESHOT), true));
}
} }
// right sidebar commands // right sidebar commands