Enable Page Reloads Even When Flash Has Stolen Keyboard Focus

Firstly, if you are not using SSL for all your sites, you should step it up! NameCheap's SSL certificates start at only $9. There's no excuse!
Firstly, if you have not tried Digital Ocean's SSD Virtual Servers for only $5/mo, I highly recommend them!

Sick of having to click elsewhere to unfocus your Flash movie in order to reload (CTRL+R, F5) the page? Splendid. Just listen for the same keyboard events in ActionScript and call the JavaScript yourself.

import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
import flash.external.ExternalInterface;

stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

protected function onKeyDown(e:KeyboardEvent):void {
    var ctrlR:Boolean = !e.shiftKey && !e.altKey && e.ctrlKey && e.keyCode == Keyboard.R;
    if ( ctrlR || e.keyCode == Keyboard.F5 ){

About this entry

Good Reads