im tryin to figure out condition AND for "shortcut" for quitting standalone app from flash. I would like to push 2 keys and combination of these two keys "C+M" should quit my app. Heres my code but its still not working. I tryed to make shure that app allow me to push multiple buttons at the same time and after that I created the function for quitting. Any answers be great.
var keyPressedC:Boolean;
var keyPressedM:Boolean;
addEventListener(KeyboardEvent.KEY_DOWN, check_key_down,false,0,true);
addEventListener(KeyboardEvent.KEY_UP, check_key_up,false,0,true);
addEventListener(Event.ENTER_FRAME, check_keys,false,0,true);
function check_keys(event:Event):void
{
if(keyPressedC)
trace("pushed C")
if(keyPressedM)
trace("pushed M")
}
function check_key_down(event:KeyboardEvent):void
{
if(event.keyCode == 67)
keyPressedC = true;
if(event.keyCode == 77)
keyPressedM = true;
}
function check_key_up(event:KeyboardEvent):void
{
if(event.keyCode == 67)
keyPressedC = false;
if(event.keyCode == 77)
keyPressedM = false;
}
import flash.system.fscommand;
stage.addEventListener(KeyboardEvent.KEY_DOWN, enterKeyHandlercm);
function enterKeyHandlercm(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.C && event.keyCode == Keyboard.M)
{
fscommand("quit");
}
}
Edited, still not working:
var keyPressedC:Boolean;
var keyPressedM:Boolean;
addEventListener(KeyboardEvent.KEY_DOWN, check_key_down,false,0,true);
addEventListener(KeyboardEvent.KEY_UP, check_key_up,false,0,true);
addEventListener(Event.ENTER_FRAME, check_keys,false,0,true);
function check_keys(event:Event):void
{
if(keyPressedC)
trace("pushed C")
if(keyPressedM)
trace("pushed M")
}
function check_key_down(event:KeyboardEvent):void
{
if(event.keyCode == 67)
keyPressedC = true;
if(event.keyCode == 77)
keyPressedM = true;
}
function check_key_up(event:KeyboardEvent):void
{
if(event.keyCode == 67)
keyPressedC = false;
if(event.keyCode == 77)
keyPressedM = false;
}
import flash.system.fscommand;
stage.addEventListener(KeyboardEvent.KEY_DOWN, enterKeyHandlercm);
function enterKeyHandlercm(event:KeyboardEvent):void
{
if (keyPressedM == true && keyPressedC == true)
{
fscommand("quit");
}
}