Reputation: 6736
Learning flex,
What would be the appropriate way to add some AS in a flex-project, giving giving focus back to the parent browser.
ctrl-q: i'm blurring flash
ctrl-t: ah, a new browser tab.
regards, //t
Upvotes: 1
Views: 662
Reputation: 76750
The following handler, as a callback for a capturing listener of the KeyboadEvent.KEY_DOWN
, might suffice:
private function handleKeyDown (event:KeyboardEvent):void {
if (event.ctrlKey) {
switch(event.keyCode) {
case Keyboard.T:
event.stopPropagation();
// open new tab
navigateToURL(new URLRequest("about:blank"), "_blank");
break;
case Keyboard.Q:
event.stopPropagation();
// remove focus
if(ExternalInterface.available) {
ExternalInterface.call("document." + ExternalInterface.objectID + ".blur");
}
break;
}
}
}
I say might because I can't guarantee you won't have to do something extra to get all browsers to behave the same.
Upvotes: 1