I moved to a new URL! Check it out!

posts tagged with: air

Disable ESC in Fullscreen on Adobe AIR

Disable ESC in Fullscreen on Adobe AIR
One of the issues with building a desktop application with Adobe AIR is that there is a built in function in the runtime that will cancel any full screen mode when the user pushes the Escape key. This is mostly a functionality of Flash, but it carries over to AIR since AIR is pretty much an extension of the Flash runtime.

Fortunately when you're using the AIR runtime you can actually override the default functionality of the Escape key and keep your application full screen when the user pushes Escape. This came up in Offspring Fling because I was using the Escape key in my UI design. The user pushes Escape to return to the main menu, pause the game, or skip cutscenes, so it was a problem when escape also canceled the game's full screen mode.

The fix for this is super easy and straight forward. First you just need an event listener on the stage for the KEY_DOWN KeyboardEvent.
//listen for key down event and trigger escOverride function
FP.stage.addEventListener(KeyboardEvent.KEY_DOWN, escOverride);
Now here's what the escOverride function looks like.
private function escOverride(e:KeyboardEvent):void {
if (e.keyCode == 27) {
e.preventDefault();
}
}

The keyCode for the Escape key is 27, so whenever a key is pressed the function escOverride is called. If the keyCode was 27, then the preventDefault() function will prevent the default action from being triggered. In this case, it's the "exit fullscreen" action.

There you have it! With just 4 or 5 lines of code total you can prevent your Adobe AIR game from canceling fullscreen when the user pushes Escape. With great power comes great responsibility. (Also note that I believe this is impossible in a normal swf build. The preventDefault() function only works in Adobe AIR.)

FlashDevelop to iPad Workflow

FlashDevelop to iPad Workflow
I recently got one of them new fangled iPad things and I heard on the internet that Adobe AIR is actually pretty decent at building things for iOS. Offspring Fling used Adobe AIR so I'm already a little familiar with how to build for Windows and Mac, but it turns out that iOS is an entirely different beast... sort of. The set up and configuration of the whole workflow can be a nightmare, but once it's over then you'll have a set up that lets you push F5 to build right to your device!

Follow along on this series of text and images and hopefully you will be enjoying pushing the F5 key on your keyboard and seeing an app pop up on your iOS device! Also put on some relaxing music because some parts of this tutorial might be hard to understand and frustrating. I'm using Windows 7 64-bit for this.

Offspring Fling Steam Achievements

Image


Just a quick post to say that the Steam version of Offspring Fling on Windows now supports achievements. I'll be adding support to the Mac version sometime down the line as well, and I'm still looking into getting the Linux version on Steam as well.

A big thanks to the folks behind FRESteamWorks! If you're an AIR developer on Steam, you definitely want to check it out.

Adobe AIR Window Scaling

Adobe AIR Window Scaling
Over the past week I added some menus and options to my Global Game Jam game remake. I'm doing this super early on in the game's life because having some awesome polished menus makes it feel like a "real" game, which motivates me to work on it more. One of the first things I did for the game options was window scaling. The game natively runs at 320 x 240, so obviously players are going to want some various scaling options unless they really want to run it at 1x and barely see the game on their screens that are now probably 4000 pixels wide.

The awesome thing about working in AIR is that it will automagically resize the game's window to the size of the flash stage, so all I have to do is set the stage width and the stage height and the window will resize to match. However, there are some funky issues that can arise.

The flash stage has different scaling modes that you can use. There's EXACT_FIT, NO_BORDER, NO_SCALE, and SHOW_ALL. For the case of this game, I'm using EXACT_FIT after I resize the window. The reason for this is so that players with super huge monitor set ups can scale the window themselves.

This was actually a problem with Offspring Fling until the lastest update. I had a player that had a desktop width of over 4000 pixels because of their multimonitor set up. They couldn't play in fullscreen mode because it would scale across both monitors, and they couldn't play in windowed mode because it was too tiny. Changing the window mode to EXACT_FIT made it so anyone can scale the window to whatever size they want. I could've also used SHOW_ALL, which would maintain the game's aspect ratio as it scaled, but some users wanted to stretch the game to fill their entire monitor. (WHY?!)