PDA

View Full Version : Exit mode in Projector ....


AlienStar
05-23-2009, 11:23 AM
hello guys

I just wanna ask ... How to show message when pressing Esc button

for example : message : are you sure to exit ??

I saw this message in nokia Projector cd show one of its phones

but I didn't know how they made it

please help me ...

northcode
05-24-2009, 08:28 AM
You can add fscommand("trapallkeys", "true") which should stop ESC from quitting your application. Then you can add your own key handler function to process the ESC key and do whatever you want.

AlienStar
05-24-2009, 09:04 AM
You can add fscommand("trapallkeys", "true") which should stop ESC from quitting your application. Then you can add your own key handler function to process the ESC key and do whatever you want.

thanks for replying but how can I add key handler function ???

please I need it so much

thanks again

northcode
05-25-2009, 01:29 AM
You do it using the Key (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary393.html) object.

AlienStar
05-25-2009, 10:23 AM
You do it using the Key (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary393.html) object.

sorry northcode I am new to flash and action script

would you like to explain more ????

coz Key object wasn't clear enough to me


thanks

northcode
05-25-2009, 02:52 PM
You have to follow the link I gave, read what's there and try some of the code. If you're not willing to do a little work then you're going to have a very short and frustrating career using Flash.

Here's how you would do it in AS2


fscommand("trapallkeys", "true");

var listen = new Object();
listen.onKeyDown = function ()
{
if (Key.getCode() == 27)
{
// ESC has been pressed
}
};

Key.addListener(listen);


And here's how you would do it in AS3


fscommand("trapallkeys", "true");

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void
{
if (event.keyCode == 27)
{
// ESC has been pressed
}
}

AlienStar
05-28-2009, 10:17 PM
thanks so much for sharing