View Full Version : A truly modal Alert/Message Box?
CDHBookingEdge
02-06-2007, 12:41 PM
Has anyone done any work on making a truly modal version of Alert?
Thanks in advance,
Christopher
wot do u mean by truly modal?
CDHBookingEdge
02-06-2007, 01:28 PM
Sorry 'bout that.
What I mean is one where something like this:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function initApp():void
{
Alert.show("Message 1");
Alert.show("Message 2");
}
]]>
</mx:Script>
</mx:Application>
doesn't show Message 2 "in front of" Message 1. IE: where the alert call doesn't return till the first message is returned by the user clicking it.
Thanks,
Christopher
You could create your one Alert class that you create the Alert instances with. If an Alert is open throw it into an Array and listen for the other to be closed before u create the next etc.
Thats still not really modal, but its the best you can do. There is no way to pause in the middle of the function while you wait for user input because flash does not support multi threading. You just have to chain functions together, for example, show alert 1, then add a event listener for when the alert is dismissed, then in that function show alert 2 and so on.
CDHBookingEdge
02-06-2007, 07:29 PM
yeah I did that for a bunch and kinda LOL got da** tired of doing it. But yeah that seems to be the only way.
CDHBookingEdge
02-25-2007, 05:08 PM
Hey I keep having this problem..it may just be a mental block as much as anything LOL. So anyway let me try to explain it.
Ok take a game that has a set of functions as such:
private var bGameOver:Boolean = false;
private var userChoosesFirst:Boolean = true;
function playGame():void
{
do
{
if (userChoosesFirst)
usrTurn = GetUsersTurn();
else
compTurn = GetComputerTurn();
} while (!bGameOver())
}
Now GetUsersTurn() will display a dialog (a popup titlewindow) and should await the users input. My question is how to I make it so that it does not "fall out" of that function until the user has closed the dialog in some shape or fashion? (Or until a predetermined amount of time has elapsed.)
Thanks in advance,
Christopher
dr_zeus
02-26-2007, 06:03 PM
You'll need to restructure your app to use events rather than a do-while loop.
You can also setup a timer to trigger the event if the user does not press anything for a certian amount of time.
CDHBookingEdge
02-26-2007, 08:35 PM
Hmm yeah maybe so...and maybe thatsame timer could check if the event has been triggered or something..oh and thanks Josh LOL though I was afraid you'd say that. It would look so much cleaner as a do while loop.
CDHBookingEdge
02-26-2007, 08:42 PM
Anyone know of someplace that might have some reasonably simple game programs with flex/flash code examples? Dunno why but my head is just really not wrapping around this.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.