This site is now just an archive over the rise and fall of Flash. The domain is available for sale
Login | Register

What is a Flash Game?

Say we decide to use Flash. We now have a bunch of MP3, SWF, and XML files. What's next? We need to be able to play these back somehow, which means using the Flash Player. But it's missing features such as fullscreen mode, support for right-click, and reading and writing save games.

By Scott Bilas, Oberon Media, Inc. Plus our SWF's, being an open format, are easily reversible, so we'd like to protect our intellectual property with some encryption or at least obfuscation.

Macromedia has a program to license source to the Player, which would let us add the features we need, but this is meant more for hardware manufacturers looking to port Flash to their platforms (cell phones, set-top boxes, kiosks, etc.). It's not a very game developer-friendly program - they want about $150,000 for the source, and royalties on top of that. This is ridiculous compared to what that would buy us in the 3D commercial engine space. So we can forget about licensing Flash's source.

There have been several efforts to clean-room engineer a Flash Player, but nearly all have fizzled out. One that continues to see regular updates is gameswf, contained in Thatcher Ulrich's public domain tu-testbed project over at SourceForge. Unfortunately, while gameswf looks extremely promising, it is OpenGL-based, and this won't work for us.

So we're stuck with the Flash OCX. We have a couple options here. Either build a host application in C++ that adds in the features that are missing, or buy one off the shelf. Putting together a host for Flash is not a trivial amount of work. We created one at Oberon using C++ and ATL 7 that adds fullscreen mode, right click handling, crash detection and reporting, support for JPEG2000 graphics, OGG and OXM playback through the FMOD library, encryption, save game reading/writing, splash screens, Flash embedding, and a bunch of other features, in a very small package. Flash can communicate with its host using async COM events in one direction, and in the other direction, perform direct variable setting/getting or function calls. This can be used to add support for any operation that Flash doesn't support natively. For example, the OCX host application would subscribe to the fscommand event, and respond to fscommand( "fullscreen", "true" ) to do its resolution changing. Macromedia has documentation on this available here:

COM events are async, which means the SWF will not be able to call a function like fscommand( "getComputerName" ) and expect to wait for a response. Flash will continue executing, and the request will not get posted to the hosting application until after some time has passed. To deal with this, we must use a sequence where the SWF makes a request, then goes about its business until the host app has a chance to receive and process the request, and then set a variable in the SWF with the results. The SWF will have to notice this independently (probably by a "watch" on the variable - a great ActionScript feature), and be able to handle the time in between. This can be annoying, but Flash developers should be accustomed to programming asynchronously - everything from loading a SWF to a JPEG to getting data from a TCP socket is all done asynchronously.

There are also some off-the-shelf packages available, such as SWF Studio from Northcode, and mProjector from ScreenTime (Google for "SWF to EXE" to find all of them). These have varying sets of features, and may include scripting and the ability to make plugins in C++ to extend the system further. As they are general purpose tools, they tend to add a lot to the size of the EXE. They will usually package the SWF's and other support files in with the EXE, along with the Flash OCX itself, to help prevent reverse engineering. Recently these types of tools have also been adding save-as-Mac EXE support. And at least one of them has managed to fix the async COM event problem, where the Flash app really can call out synchronously to its host to get information. These tools are always royalty-free and so cheap that they're essentially free, and worth checking out.

So here are the pieces in our game: the "projector" EXE, the Flash Player OCX, and the content in SWF's, XML files, and other resource formats. This can be distributed royalty-free - Macromedia basically only requires some minor logo placement when we use their Player. Be sure to check the license agreement for all the details.
Developing with Flash >>>


Next tutorial:
Developing with Flash

Previous tutorial:
Flash Resources

Get new stories first

Click to follow us on Twitter!



No comments for this page.

Submit a comment

Only registered members can comment. Click here to login or here to register