NativeWindow class in AIR does not support Flex components

Just a quick tip for any AIR developer’s searching for why there’s no addChild method in the NativeWindow class – I wasted a fair while on this over the weekend. I was adding Flex components to the stage property of NativeWindow and trying various other work arounds. Although you don’t get errors for doing this the Flex components never appear when you test your app!

If you want to add Flex components to a new NativeWindow in AIR then this is what Window class is for. So don’t waste time creating a new NativeWindow and activating it, just create/subclass the Window class not NativeWindow and you’ll find all the stanard Flex component properties and methods 🙂


Scoop – a new Feed RSS Reader for Mac, Windows and Linux – synchronizes with Google Reader

Scoop is a new piece of software I’ve been developing in my spare time with Adobe Flex Builder and AIR. It’s really starting to take shape and I’m hoping to be in a position to release the first beta version within the next couple of weeks.

For anyone not familiar with RSS Feed Reader’s in summary they allow you to subscribe to multiple RSS news/blog feeds which you’ll find on tonnes and tonnes of websites and blogs in cyberspace. So, every time one of these websites posts a new story on their site the story or summary gets added to their site/page RSS feed – text, images and other media can also come through the feed.

You’ll see links to these RSS feeds on almost all the blog front pages out there and also on many information sites, whatever your interest – News sites, Sports sites, Celebrity Gossip sites etc etc

There’s a great browser based application called Google Reader which enables any google account holder (if you don’t have one already sign up for free here) to easily add any RSS feed to their Google Reader account and keeps track of all your subscribed feeds enabling you to quickly scan the latest scoops of your favorite sites every time you log into Google Reader.

Scoop will enable users with or without Google Reader accounts to keep track of their favorite sites directly from the Desktop. It will also synchronize with your Google Reader account so any story you read in Scoop will update Google Reader’s read items, any feed you add or remove will also update with Google and vice verse.

But there are added benefits to Scoop that a web browser can’t offer, here are just a few:

  • Scoop will offer alerts so that you never miss a breaking story
  • Scoop will cache all the stories it downloads enabling you to read them on the train when you don’t have an internet connection plus will will auto update google the next time you do connect to the net
  • Scoop is super quick – no waiting around for stories to download (it’s already cached them locally!)
  • Scoop enables you to enter multiple profiles/settings. This means that it can synchronize with multiple Google accounts (optional). I think this provides a great way to segregate different main interests. Ie, I’ve got an account which keeps track of my favorite Flash/Flex blogs but I’ve also set another one up to keep track of my favorite news feeds. The Alerts feature of Scoop is going to enable you to set the alert frequency and colour code different Scoop profiles so that you can quickly register the type of new Scoop update.

Anyway, here are a couple of screen grabs of the current development version which is not quite ready for public download but will be very soon – why not subscibe to this blog feed or the Scoop specific blog I’ve set up so you’ll know as soon as it does go public?

Scoop Profile settings window - enables users to add multiple rss reader accounts

Scoop Profile settings window - enables users to add multiple rss reader accounts

Scoop quickly syncronizes with my Google Reader account

Scoop quickly syncronizes with my Google Reader account

As soon as I select a feed from the tree list the stories associated with that feed are loaded into the reading panel

As soon as I select a feed from the tree list the stories associated with that feed are loaded into the reading panel

BTW – I’m no designer – so if there are any good designers our there interested in contributing to this project and designing a cool Flex skin for the application I’d love to hear from you!

Auto centre main AIR Application window with code

Here’s a tip for how to centre (center for you yanks) your main Adobe AIR application window at runtime. It’s not as obvious as this.x = numX, this.y = numY for some reason. All this does is ends up moving you application container out of the NativeWindow masked view. Not what I was after.

You can set the initial position of your main application window in your app descriptor xml (although I can’t see the point of this as most developers are going to want it set dynamically based on the dimensions of the user’s screen).

So here’s the code that get’s called once the windowComplete handler is called:

private function centreApp():void
var screenBounds:Rectangle = Screen.mainScreen.visibleBounds;
var w:int = width;
var h:int = height;

var x:int = screenBounds.x + ((screenBounds.width-w)/2);
var y:int = screenBounds.y + ((screenBounds.height-h)/2);
stage.nativeWindow.x = x;
stage.nativeWindow.y = y;
visible = true;

In the main application I’m building I’m using the PureMVC Flex Framework and I’m not actually running this code snippet until my config xml and my styles swf has completed load into the main application so my code retains full control of when the application displays and where it displays 🙂

Download the App

Download the Source