Many claim that “Flash is dead,” but I believe that in the world of gaming, this is not so. One of the reasons is a framework called Starling.
Starling is a free open source Actionscript 3 library which renders its content by using Flash’s Stage 3D technology. What does this mean? Faster performance which makes use of GPU hardware acceleration. The ever-so popular game Angry Birds was built using this framework.
Screenshot from my Starling game demo example
After trying out Starling on my own, I was pretty amazed by a few things:
1. Quick setup.
It is simply a swc file that you include in your library. Then, create a Startup class that will instantiate and start up the Starling instance:
[SWF(width="400", height="300", frameRate="60", backgroundColor="#ffffff")]
public class Startup extends Sprite
private var _starling:Starling;
public function Startup()
_starling = new Starling(Game, stage);
The “Game” parameter of the constructor expects a class that is a Starling display object.
2. Ease of use.
You can then go on your merry way writing AS3 as usual, but instead of using the regular Flash display classes, use the ones in Starling. Since I use Flash Builder, the IDE would often automatically import “flash.display” classes; you’d have to replace those with “starling.display.” Also, loading images is a bit of more work than loading an image and adding it to the display list. Starling uses a Texture class that contains an image’s data, and then it uses an Image class to render that data:
// load background
loadBackground( _gameModel.bgImagePath );
* Load background image.
* @param url URL of background image.
* TODO: Create image loader utility class that all image loading can use, then dispatch event when that particular image is ready.
private function loadBackground( url:String ):void
_loader.load( new URLRequest( url ) );
* On load background image complete.
* @param event Flash event for event complete.
private function onLoadBackgroundComplete( event:flash.events.Event ):void
// add background to display list
var loadedImage:Bitmap = event.currentTarget.loader.content as Bitmap;
var image:Image = new Image(Texture.fromBitmap(loadedImage));
3. Awesome performance.
The smoothness of Starling is impeccable, but I am sure it is even more evident with the more graphic-intensive games out there (like Angry Birds). With Starling’s awesome performance and with Adobe Air (and even Flash CS5.5+)’s ability to deploy to iOS and Android, who says that Flash is dead? 🙂
Check out my source files and you’ll find how quick and easy it is for AS3 developers to jump onto Starling!