ScreenCapture class, demo app and screencast
I felt like working on something new this past weekend, so I devoted a few hours to the new AIR 2.0 Beta. One feature that really caught my eye is the NativeProcess class, which allows developers to communicate with the system through an executable. This is a game-changer in the AIR world, opening more doors than you or I can ever imagine. I’ve always wanted screen capture support in AIR, so with this new class, I developed it myself.
Surprisingly, my efforts proved successful!—I had a working class, ScreenCapture, and application, ScreenCaptureDemo, up and running within a few hours. Tired of staring at the Spark components, I decided to add a touch of DT to the app by designing my own skin. This took far longer than the core of the app, but made a world of difference. Now that I think of it, this could be considered my first Flex app.
The downside of the NativeProcess class is it nulls the cross-platform benefit of AIR. The developer must compile a .dmg for Mac, a .exe for Windows, and the choice between a few for Linux. Since I only spent this weekend on the ScreenCapture class and I’m only familiar with the Mac command line, both the class and demo app are Mac-only. Also, the demo won’t work just yet for most of you. It requires a prerelease build of AIR 2.0, but things should be okay once the Beta 2 is out.
Download ScreenCaptureDemo (Mac-only, requires AIR 2.0 prerelease)
Along with adding the ScreenCapture class to DestroyFramework, I created a repository for the ScreenCaptureDemo source and installer on GitHub as well. Check them both out and enjoy!
[note] I’m not quite sure why Vimeo decided to cut out the right audio channel in the screencast…

I don’t know of I have been mispronouncing ‘gif’ for my whole life, but I heard you say ‘jif’, twice.
Very nice Jonnie, and thanks for posting the source on Github. I look forward to digging into this.
@Carey — Ha! I’m a strong believer in the “jif” pronunciation—been saying it all my life and realized just last year some people say “gif”.
@Brian — Dig! and fork!
good fun! thanks for sharing this!
Hahaha – Jonnie loves his peanut butter!
Very nice !
This could be really useful for debugging. Imagine an AIR game that automatically takes a screenshot of itself every time an error is logged. That would be very useful for bug reports! Thanks for the class, the article, and the screencast.
Hi Jonny,
Can we have the ability to screen capture in Destroy Twitter and upload to our chosen image sharing site?
@Matt — That could be a great feature and one I’ll consider. The only downside of using NativeProcess is it must be compiled to a native installer, so I couldn’t provide just an AIR file, it’d have to be a DMG.
This is awesome. I had actually built a similar app during the beta, but lost it after a harddrive crash.
Anyways, two feature suggestions:
Integrate with the Flickr Uploader Mac app. Basically, you can just pass the path to the image on the command line to the Flickr app (if the app isnt installed, then dont show the option).
Drop box support. Make a preset so you can put it in your dropbox public folder. This makes it super simple to take a screenshot and send it to someone over IM.
Finally, open in photoshop.
Great app. Super useful.
mike chambers
@Mike — Thanks! Since this is simply a demo app for the class, I don’t really have plans to maintain it. I’ve taken a liking to these small apps/experiments and posting the source to GitHub. This way I have a life after work and fun when I feel like developing something. These feature requests are tempting though