Keyboard Focus
Submitted by rosenz on Mon, 03/30/2009 - 16:17.I've been asked by several people over the last few months about keyboard focus for Flash games running in the browser. Usually, the person asking is quite sure what is going on. All they know is that the game doesn't work when the browser first loads it, at least until they click on the game. Then it works.
What is happening here is simply a matter of keyboard focus. When a game, or any Flash movie, loads in a browser the focus of the keyboard is still on the browser. The "focus" simply refers to where the key presses trigger events. So if the browser has keyboard focus, then the browser gets key presses for filling in form fields, entering URLs or search box contents, or executing keyboard shortcuts.
If the user presses the up arrow, for instance, the browser gets that key press and probably tries to scroll up on the page. The Flash movie on the page never even hears about the up arrow being pressed.
To switch the keyboard focus to the Flash movie, the user simply needs to click on the Flash movie. This is the same for anything in a modern OS. If the user clicks on a Finder/Explorer window, then the keyboard focus switches to that. If they click on a word processing window, then the keyboard focus switches to that, etc.
Now, you can also perform some embed/object tag and JavaScript mojo to set the keyboard focus. But that is going overboard. You can simply make sure that the user clicks on your game by including a splash screen and a "start game" or "play" or "begin" button. That's good design anyway, as you don't want most games to start the minute the page loads.
FlashGameU.com Video Tutorial: Catching Game Part 2
Submitted by rosenz on Thu, 03/12/2009 - 19:16.Gary Rosenzweig builds a catching game in Flash ActionScript 3.0. In this part, you learn how to have a bucket move with the cursor at the bottom of the screen and catch objects. Some are good and some are bad, and the score changes based on what type of object is caught. You can find full resolution video and more podcasts at FlashGameU.com.
Download the source code (final game, parts 1 and 2).
FlashGameU.com Video Tutorial: Catching Game Part 1
Submitted by rosenz on Wed, 03/04/2009 - 18:43.Gary Rosenzweig builds a catching game in Flash ActionScript 3.0. In this part, you learn how to have objects fall from the top of the screen, taken from various movie clips in the library using arrays of strings to determine which movie clip is created and dropped.
Download the source code (final game, parts 1 and 2).
FlashGameU.com Video Tutorial: Communication Between Movie Clips
Submitted by rosenz on Tue, 12/23/2008 - 17:32.Gary Rosenzweig looks at ways movie clips can communicate with each other in Flash ActionScript 3.0.
FlashGameU.com Video Tutorial: Understanding the Display List
Submitted by rosenz on Tue, 10/21/2008 - 16:25.Gary Rosenzweig talks about display lists and how you can manipulate them to move display elements ahead or behind others.
FlashGameU.com Video Tutorial: Dynamic Filter Effects
Submitted by rosenz on Wed, 09/03/2008 - 17:30.Gary Rosenzweig shows you how to apply dynamic filter effects to a movie clip, such as glows, drop shadows and bevels. You can find the source files, full resolution video, and more podcasts at FlashGameU.com.
FlashGameU.com Video Tutorial: Pausing and Resuming Sound
Submitted by rosenz on Wed, 08/13/2008 - 20:45.Gary Rosenzweig, author of ActionScript 3.0 Game Programming University, shows you how to pause a sound in AS3 by recording the position of the sound before stopping it, then resuming the sound at that same position.
FlashGameU.com Video Tutorial: Game Inventory System
Submitted by rosenz on Tue, 07/15/2008 - 17:28.GGary Rosenzweig looks at a basic game inventory system created with Flash ActionScript 3. Using an Inventory object, you can allow the player to add items to their game inventory. Then you can let them click on the items to use them, or test the inventory contents to allow them to complete tasks in the game.
FlashGameU.com Video Tutorial: Simple Particle System
Submitted by rosenz on Thu, 06/12/2008 - 17:48.Gary Rosenzweig, author of ActionScript 3.0 Game Programming University, shows you how to create a very simple particle system using a class and by adding and removing movie clips from the display list.
FlashGameU.com Video Tutorial: Continuous Animation
Submitted by rosenz on Thu, 05/29/2008 - 18:53.Gary Rosenzweig, author of ActionScript 3.0 Game Programming University, answers a question in this podcast of how to maintain continuous animation while receiving user input. The character on the screen continues to follow a walk animation even while the player triggers the animation over and over.
Copyright Gary Rosenzweig
