Starling 1.4

Daniel Sperl on September 24, 2013

Time flies by, doesn’t it? Believe it or not, it’s already been more than half a year since the last Starling version was released. In other words, it’s high time for an update!

Ladies and gentlemen, please buckle up: Starling 1.4 is AIR-borne!


This release is all about polishing. There are countless behind-the-scenes modifications that will make your game run faster and more stable, without you having to change anything in your code. We also made sure that all of the new AIR features are supported, e.g. the new texture options (4k support, rectangle textures, 16 bit textures) or even iOS background execution (coming with AIR 3.9).

But this wouldn’t be the Starling Framework if we hadn’t added some nifty new features, as well! Let me take you by the hand for a tour through the most important ones - ordered by coolness factor. ;-)

Performance Updates

Throughout the framework, I made lots of changes to make it more efficient.

  • One example: the ENTER_FRAME event is now dispatched in a smart way, involving only the objects that registered for that event type.
  • Another: we optimized the matrix calculations inside the DisplayObject class (important for the rendering of animated objects).
  • Furthermore, we used Scout to track down lots of hidden memory allocations caused by the AOT compiler. Avoiding those allocations reduces the strain on the garbage collector, and your game will run without hiccups.

All in all, you can expect about 10% better performance in your games!


You can now easily add a rectangular mask to any sprite. The new “clipRect” property can be set to an arbitrary rectangle; only the contents within this rectangle will be drawn. The nice thing about this feature is that it’s very cheap: it comes at the discount price of just one additional draw call!

sprite.clipRect = new Rectangle(20, 40, 200, 100);

To see it in action, you can navigate to the “Clipping” scene in the Starling Demo.


This is a feature I’m especially happy to announce. You might know the DisplacementMapFilter from conventional Flash; a gem that is often overlooked, but very powerful! It allows you to dynamically distort the pixels of a display object. If you master this filter, you can do all kinds of amazing special effects. Here is one such sample: a dynamic reflection on water.

To add such an effect to your own games, just copy & paste this code.

Better handling of Lost Context situations

On all devices except Apple’s, you have to activate “Starling.handleLostContext” to be sure that your game doesn’t crash when the system loses the device context (for whatever reason). Previously, Starling kept all the texture data in memory to be able to restore those textures in case of a context loss.

The new version, on the other hand, will load the textures from the original sources instead. This means that the overall memory consumption of Starling is reduced by about 50%. That’s a huge difference, especially on mobile!

If you use the AssetManager class, this will be done automatically for you. Update to Starling 1.4, and you’re done!

If you manage your assets manually, it’s not a problem, either. You can easily implement the optimization yourself. Just make use of the new “onRestore” callback on textures; this callback is executed when the context is lost. Here’s how to use it:

texture.root.onRestore = function():void
    // restore the texture from its original source
    texture.root.uploadBitmap(new EmbeddedAsset());

The callback restores the texture from its original source (e.g. a file or an embedded asset); thus, you don’t need to keep your texture in memory.

Enhanced AssetManager

Besides the automatic context loss optimizations, the AssetManager has learned several other new tricks. In addition to textures and sounds, it can now handle generic XML, JSON and even raw ByteArrays.

  • As before, any PNG, JPG or GIF file will be available as texture,
  • any MP3 file as Sound and
  • atlas textures and bitmap fonts are recognized automatically.
  • New: enqueue a JSON file and you’ll get a generic ‘Object’ initialized with the corresponding data. Great for game configurations or translation data.
  • New: enqueue a generic XML file and it will be available as such.
  • New: all other data will be available as a raw ByteArray.

Support for 4k- and RectangleTextures

From all the requests I received in the past, this is probably the one that came up most often: is there a way to use textures that are bigger than 2048x2048 pixels?

Well, now there is! In fact, that’s a feature of AIR 3.8: just start up your game with Context3DProfile.BASELINE_EXTENDED, and your textures may be up to 4096x4096 pixels big. (Be sure to check if your device supports that, though!)

The second useful addition to AIR is a new low-level texture type: RectangleTexture. As you probably know, all Stage3D textures needed to have power-of-two side-lengths in the past. Starling hides this limitation from you, but at the cost of additional memory.

Starling 1.4, on the other hand, will automatically use a RectangleTexture internally if it’s possible - saving some more memory. (Supported beginning with the BASELINE profile.)

HiDPI aka MacBook Retina Support

To make use of the amazing resolution of the latest MacBooks, you can apply the same techniques you’re used to from your mobile games. Just load your textures with a scale factor of two and set Starling’s new “supportHighResolutions” property to “true”. That’s it!

If you are in the privileged position to read this blog entry from such hardware,

  • I envy you ;-)
  • Look closely at the reflection demo from above, and you’ll see that it uses the full resolution.

Other Features

As always, there’s just not enough space to show you all the changes since the last release. And this release has the biggest changelog of all! Here are some of the most notable other modifications:

  • added TextField.autoSize
  • added stage.drawToBitmapData, allowing you to make a screenshot of the stage
  • added support for the new “packed” texture formats and runtime texture compression (the latter being Desktop-only)
  • added support for the updated ATF file format
  • added ‘suspendRendering’ argument to ‘Starling.stop()’ method (for AIR 3.9 background execution)
  • added Event.TEXTURES_RESTORED, dispatched by AssetManager after context loss
  • added support for custom touch processing (TouchProcessor subclassing)
  • updated Keyboard events: they are now broadcast to all display objects
  • ‘DisplayObjectContainer.sortChildren()’ now uses a stable sorting algorithm
  • fixed multitouch support on devices with both mouse and touch screen
  • fixed some bugs with special cases in ‘MovieClip.advanceTime()’
  • fixed missing HOVER event after ended Touches (caused hand-cursor to appear only after movement)


What do you think? Definitely worth the upgrade, right? Let me know your thoughts in the comments below!

As always, I received a lot of help from the community. Countless of your bug reports make this the most stable release ever, and some of the features are a direct result of a pull request or a lengthy discussion in the forum. Thanks for your continuing support! Starling wouldn’t be where it is today without you, guys.

One more thing, before you head over to the download section: our “No-Fuzz Game Backend” service, Flox, is nearing the end of its “Beta”-phase! So, if you haven’t done so already, be sure to check it out, too.