Starling 2.7

Daniel Sperl on August 1, 2021

Starling actually celebrates its tenth birthday this year – isn’t that incredible?

I can still vividly remember my excitement when I discovered the email from Adobe’s Thibault Imbert in my inbox, with his proposal of porting my Objective-C framework, Sparrow, over to the Flash API and the (then) brand-new Stage3D API. A few months and many long nights later, I could proudly announce the new little framework in this blog post.

Starling was still a little rough around the edges back then, but the amazing Flash community still embraced it, and it became more popular than I could ever have hoped for!

Of course, in the world of software development, 10 years are an extremely long time! To put this in perspective: the now omnipresent NPM was first released just a year earlier; and Adobe’s introduction of the Creative Cloud followed only in 2013. Shortly after Starling’s release, Apple released the iPhone 4S, only the second iPhone to feature a retina display.

Fast forward to today – the Flash Player has been removed from all major browsers, Adobe stepped out of AIR development, and JavaScript is ruling the world. Plus, well, a pandemic has been rolling across the face of the earth (though we probably can’t put blame on JavaScript for that). What a ride!

Against all odds, though, AIR is still around, and it’s actually in a much better position than many had feared after Adobe’s withdrawal. That’s mainly because of the great efforts from Harman, who’s passion for the project really shows in every aspect of their work. And for those areas where AIR can’t provide a solution, distriqt takes over with its excellent native extensions (plus, I might add, excellent support).

So it’s high time that our little bird follows the lead, puts on its best feathers, and celebrates its 10th anniversary with a brand new release!

Starling 2.7

The focus on this release is actually not so much on the library itself, but on simplifying several tedious development tasks that were brought on to us by recent changes from Apple and Google - mainly in the form of a greatly updated ‘Scaffold’ project.

For example, you can’t really create an app nowadays without taking the ‘notch’ of modern iPhones into account, or the ‘display cutouts’ from Android. While AIR doesn’t contain an API to query this information just yet (though it’s in the works), the Application ANE from distriqt fills the gap wonderfully. Starling’s updated scaffold project now acts as a sample implementation that shows you how best to use it.

Creating application icons for iOS and Android hasn’t become any easier, either. You now need to create them with Xcode and Android Studio before adding them to your AIR project.

Again, the scaffold acts as a showcase as to how it’s done. For example, it makes us of the new resdir element inside the application XML to point the AIR packager to the required Android resource folder.

My recommendation: read through the excellent documentation from distriqt regarding iOS icons, Android Adaptive Icons, and Android resources; then use the scaffold project for a reference and/or starting point to make use of these techniques with Starling.

I also used this opportunity to clean up the samples folder in general.

  • After the demise of the Flash Player, the “web” sample doesn’t make much sense any longer, so I ditched it.
  • Adobe Flash Builder is all but abandoned, so I removed all those old project files, too.

In exchange, all projects now contain project files for Visual Studio Code, to be used with Josh’s excellent ActionScript & MXML extension, as well as module files for IntelliJ IDEA.

Hopefully, these changes make it easier to get started with any project you’ve got in mind!

API additions

Even though the changes to the Starling API are small, I hope they are still useful to some of you!

The Statistics Display now shows the number of frames that are currently being skipped per second. Remember, with starling.skipUnchangedFrames enabled, Starling will skip rendering of any unchanged frames, which is a fantastic way to reduce battery consumption. With the updated statistics, it will be easier to optimize your code for this setting.

If you need to get this information directly in your code, Starling now dispatches Event.SKIP_FRAME.

Other notable API changes:

  • The new methods BlendMode.isRegistered() and BlendMode.getAll() make it easier to work with custom blend modes.
  • The RenderTexture constructor now contains the parameter forcePotTexture (thanks to hardcoremore!)
  • Canvas.drawCircle() and Canvas.drawEllipse() can now be passed a numSides parameter.
  • BitmapTextureFactory and AtfTextureFactory now support the TextureOptions.onReady callback (thanks to esidegallery!)
  • The Android back gesture is now ignored by default (via starling.discardSystemGestures)
  • Several small fixes and enhancements.

Adobe Package Manager

One thing that’s so great about AIR is its huge standard library, containing a plethora of ready-to-use functionality. That’s the reason, for example, that Starling gets away with not having a single other dependency than AIR itself.

In other (not to be named) languages, you’re quickly ending up with a node_modules folder weighing a few hundred MBs, just for a few dependencies … (cough).

However, one has to admire how easy it is to handle those packages with the likes of npm and gem. One command on the terminal, and the dependency is downloaded and added to the project.

Thus, I was thrilled to read Michael Archbold’s announcement in the Starling Forum that he was working on a package manager for AIR! By now, the first beta of the AIR Package Manger has already been released – and of course, Starling is part of it from day one.

So, once you’ve got apm set up, you can grab the latest release just like this:

apm install starling

That’s it! This will download the Starling SWC file to the lib folder of your current directory. Is it just me, or does this feel like a breath of fresh AIR?!

Of course, this really shines when we’re talking about native extensions, which tend to become quite painful to update otherwise.

Thanks a lot to Michael and the complete team from distriqt for their great work!

That’s it, folks!

It’s been a real pleasure for me to get back into AIR development for this update, and to finally be able to work on another Starling update – even though it’s a little smaller than usual. I hope you enjoy using the latest version just as much.

Stay healthy and safe, my friends!