How to Learn Flash and AS3 for Game Development
Today, Adobe Flash is strongly geared towards game development. Besides browser-based game portals like Kongregate, Newgrounds, and Armor Games, games made with Flash can be found on desktop, mobile, and tablet (like Machinarium, Super Hexagon, and Wonderputt), as native apps. In this article, we’ll share books, tutorials, and suggestions for learning Flash and its AS3 programming language as smoothly as possible.
Isn't Flash Dead?
Flash has had a tough time over the past few years. Steve Jobs didn't like it. iPads, iPhones, and newer Android devices won't run it in the browser. HTML5 has been improving rapidly, allowing browsers to do new things every day that were previously only possible with Flash. And everyone's come across an annoying banner ad made in Flash, or had the Flash plugin crash and take the whole browser with it.
So Flash gets a lot of bad press among web developers and the general public, and it's certainly an obsolete choice today in many areas where it used to be king, such as multimedia website development. But it is still an excellent platform for game development.
Why Flash Is Still Great for Gamedev
One reason for this is the technology. Flash's default programming language, AS3, is a far cry from the ActionScript of years past; it's a powerful, object-oriented programming language with hardware acceleration, online networking capabilities, and support for 3D graphics. Plus, although Flash Player isn't supported by most mobile and tablet browsers, Flash games can be exported as native apps for iPhone, iPad, Android, Kindle Fire, and BlackBerry.
Another reason is the ecosystem. Flash web portals may have started out as sites for kids to host their crude stick-figure games, but they now make up a multi-million dollar industry, with many technically complex games and critical hits. And since Flash games can run on mobile and tablet devices, they can be sold in the App Store, Google Play Store, Amazon Appstore, and so on.
The other big reason, in my opinion, is the community. Due to Flash's peculiar evolution, it appeals to both designers and coders - a perfect melting pot for game development. As well as forming a great community to be part of, Flash game developers have written a lot of useful libraries, tools, books, and (of course) tutorials.
But... HTML5!
I'll admit, there's a kind of online peer pressure against using Flash for any purpose, and this can be discouraging. In any discussion about Flash, regardless of context, someone will jump in and tell you that you should be using HTML5 instead - it's like Godwin's law for web technologies.
It is worth looking into HTML5 as well - it's worth learning several different platforms - but don't overlook Flash's many strengths. The situation is not as simple as "HTML5 is Flash's replacement".
Besides all those commercial reasons, as Will Blanton said in a recent conversation about this:
I love being exposed to new technologies, but gamedev isn't just technology, it's a medium for expression (art), and it's just uncouth to demand an artist change his or her toolset to reflect some kind of perceived global zeitgeist.
Installing Flash Development Tools
You do not need a copy of Flash Professional in order to make Flash games. It's fairly useful as a tool for putting together GUIs and animated sprites, but it's not great for writing code.
Instead, if you're on Windows, I recommend you download the free FlashDevelop code editor - it's my personal favourite. I've written a beginner's guide to it, and there's more information at the official website.
Unfortunately, FlashDevelop is only on Windows. If you're on a Mac, give FDT a try - there's a free version that should be more than enough to get you started. Michael Plank wrote a great beginner's guide to the editor, and there's full documentation (including a Getting Started guide) on the FDT homepage.
If you own an Adobe Creative Suite collection, or you're a subscriber to Creative Cloud, you may already have a copy of Flash Builder, Adobe's own code-focused Flash editor. Check out this guide to learn how to get started with it.
Finally, you don't actually need a fancy IDE to do Flash development; you can use any text editor to write your code (John Cotterell pointed me towards Simon Gregory's AS3 TextMate bundle, for instance) and the Flex/AIR SDK to compile it - although I wouldn't recommend this if you're new to programming.
Don't spend any time worrying about which to choose - you can always switch editor later.
Learning AS3
AS3 (ActionScript 3.0) is the de facto programming language for Flash. (There are alternative languages - such as the older AS2 and the cross-platform Haxe - but I'm not going to touch on them here.) If you want to make Flash games, you'll need to learn to program. Rather than teaching to learn how to code and how to make games at the same time, it's easier to start with coding. Yes, this means building things that aren’t games, but this will help you make games in the long run.
If you already know Java, C#, or another OOP language, AS3 won't be a big stretch for you. You should, however, read up on:
- The Display List - see AS3: The Display List, Display list programming in AS3, and AS3 101: The Display List.
- The Event System - see Introduction to event handling and AS3 101: Events.
- Garbage Collection - see Understanding Garbage Collection in AS3.
If you're new to programming in general, you'll need a more comprehensive guide. I recommend AS3 101, an 18-part series explaining all the core concepts from scratch.
Two books I'd also suggest getting (and reading cover to cover) are Essential ActionScript 3.0) and Foundation Actionscript 3.0 Animation: Making Things Move!. Don't be fooled by the title of the latter - it's not about typical hand-drawn animation; it's about using code to, well, make things move. That's extremely relevant for game development!
Alternatively, Matt Barker recommends this huge (600 page) free guidebook, by Adobe: Programming ActionScript 3 [pdf].
You'll need a reference guide as well. The Adobe Livedocs are great, and in most cases will be all you need. (The search is a little wonky, but if you just Google for [livedocs «term you actually need»] it'll turn up.)
And as with any programming environment, Stack Overflow and the Gamedev Stack Exchange are great technical Q&A sites. The AS3 tag is actionscript-3
.
Making Your First Games
There are a lot of books and tutorials specifically about Flash game development, but it's tricky to find one that uses good practices without assuming too much prior knowledge.
I think the best in this category is AdvancED Game Design with Flash. You should be able to understand it if you've got to grips with AS3 from the previous recommendations, even if you have little or no actual game development experience.
I'd like to include a few free online tutorials here as well, to go alongside (or even to replace) that book... but I don't actually know of any comprehensive tuts that fit the bill. Most Flash gamedev tutorials seem to assume that you either know very little about AS3, or you have enough game development experience to use a specific library or framework.
Of course, there are tutorials out there - just nothing definitive. Take a look through the Activetuts+ Games archives, explore Everyone's Platformer, and try at least making something simple like Pong or Space Invaders to learn the basics.
More, More, More
You've got to grips with the Flash Platform, you can code in AS3, and you've got a decent foundation in Flash games development. At this point, you can follow most of the Implementation tutorials on this site, even if they're written in a different development platform.
But there's still so much more you can learn about Flash game development specifically! I've rounded up a set of resources, in no particular order - choose whichever you're most interested in right now, and get learning.
Flash Game Engines
Flixel and FlashPunk are two popular, free, open source libraries tailored for 2D game development.
Both are well supported, with a keen community and a lot of tutorials, and each has been used to make a ton of games.
To learn Flixel, take a look at the links on the official Help page, as well as Photon Storm's excellent collection of Flash Game Dev Tips.
To learn FlashPunk, check out the official tutorials.
You may find this library more comfortable if you already have experience with Game Maker, as it was based heavily on the Game Maker scripting language.
Stage3D
The Stage3D APIs allow you to use GPU hardware acceleration in your games, for super-fast 3D rendering. Check out Christer Kaitila's book, Stage3D Game Programming: Beginner's Guide, for an in-depth guide to this.
(It's also worth looking into Away3D, an advanced 3D engine for Flash.)
Despite the name, Stage3D is also great for 2D games, giving common rendering speeds of 60fps. Christer has also written a six-part tutorial series on building a 2D shoot-'em-up using Stage3D - the first three parts are totally free!
If you want to take this further, look into Starling Framework, a library specifically designed for 2D game development, giving you the power of Stage3D rendering without having to touch Stage3D itself. Thibault Imbert has written an introduction and a great ebook for the framework - both of which are free!
Mobile and Tablet Development
As I mentioned at the start of this article, Flash does not confine you to browser development - you can make games that run as native iPhone, Android, or BlackBerry apps, and even sell them on the various app stores.
Actually getting your game to export in native app format is not particularly difficult - just Google [flashdevelop android]
or [fdt ios]
or whichever other combination of tools and platform is appropriate for you to get the latest instructions.
What's harder is optimising your game for another platform, and making use of hardware features like the accelerometer and touch screen. I recommend the Flash Development for Android Cookbook and the Flash iOS Apps Cookbook for this, accompanied by regular reading of our sister site Mobiletuts+ to learn about mobile interface design.
Miscellaneous
There are many more libraries I could go into - like Box2D, GreenSock, and MinimalComps - but I need to stop somewhere.
I'll round off this list with some great websites for Flash game developers:
I just know I have missed some excellent sites off that list. Please leave a comment if you think something deserves to be added!
Make Games
I said this in the XNA guide, and I'll say it again here. When you're getting started, don’t make something complex like an MMO, or anything that requires huge amounts of artwork and story like an RPG. Begin with something simple that you might be able to expand upon later.
For example: a single button game like Canabalt could be extended to create a platformer; a Pong clone could be turned into a brick-breaking game with multiple levels; an avoider game could become a space invaders clone and then a full-blown shoot-’em-up.
Don’t worry about learning advanced programming techniques quite yet, either; you’ll have time to get to grips with design patterns and general code architecture later. Focus on finishing some games, even though your first ones will only be small.
Big thanks to Djordje Radakovic, Matt Barker, Joseph Burchett, Will Blanton, and John Cotterell for their help in putting this guide together!
If you have any suggestions for Flash and AS3 learning resources that we’ve missed, please let us know in the comments.