Getting assets (such as images and sound files) into your AS3 project can be simple, but I ran into a few problems (and nice solutions!) that might help others out too. I thought I’d jot it down into a blog post!
How I used to do it
I use FlashDevelop, and I try to avoid using the Flash IDE for development. I found it incredibly handy, though, that I could copy any asset – even vector art – with a simple drag-and-drop into Flash, and export the whole bundle as an .SWC file.
FlashDevelop is awesome handling SWC files; a simple pair of clicks gives you full access not only to the assets, but any sub-classes and properties the assets may have (as imbued by Flash itself). It’s quite awesome, and it’s how I’ve done everything to-date.
There are a few downsides to Flash’s SWC asset library:
- Porting to other platforms or languages (that don’t support Flash files) is a pain in the butt; without SWC support you have to re-invent your asset importing routines for each platform.
- Even when sticking with Flash, importing assets into Flash that you’ve already separated out into individual files can be annoying and tedious (as opposed to developing all your assets within Flash or Illustrator)
- You need to own a copy of the Flash IDE (the Professional version, too, if you want to make commercial projects)
The first item on that list is the one that bugged me the most. No other development environment has a standardized equivalent to the SWC Library; converting your game to any other platform or language suddenly gains an extra hurdle, and requires exporting of assets and all sorts of hoop-jumping. I know this first hand; there was some problems creating the mobile editions of Steambirds.
When I look at various Flash blitting/game engines, such as Flixel and FlashPunk, and they tend to support sprite sheets, image file imports, and other such “industry standard” ways of doing things. Converting from these engines to – let’s say, iPhone – will be a whole lot easier.
There’s just one little thing standing in the way of me following in their path…
I hate SpriteSheets
SpriteSheets were invented by old console programmers that couldn’t manage their assets with the hardware they had. Instead of making large images, they’d break everything down into sprites – dump them all into a single crammed-in file, and re-construct environments piece-by-piece. This is what gives Super Mario Bros. that square look, and why so many games seemed to be built on a grid.
SpriteSheets nearly require you to make all of your assets the same size, and even if you don’t: Any time you save managing dozens of tiny files will be made up in creating a lookup table (or a map) to your spritesheet.
Well, the standard way is to “simply” use three lines of code to “Embed” each graphic file – at compile time – to your Flash application. I’d love to do this, but I have over 200 files to import! That’s a lot of typing!
Some helpful Twitterites suggested I might want to look into streaming the files off of a server – but that brings up bandwidth and offline-compatability concerns (but is otherwise a great idea).
Whatever am I to do?!
@ChevyRay to the Rescue
Chevy, the best thing to happen to GDC 2011, took it upon himself to whip up an AIR application that automatically generates all my Embed tags for me, and stores them into a centralized art asset file!
Download his quick-n-dirty tool here: chevyray.com/stuff/AssetBatcher.zip
It did exactly what I wanted it to, simplified a lot of work, and has made my future projects even more cross-compatible with other platforms (and easily portable to other languages).
Thanks Chevy!! <3