Flex BrowserManager + SWFAddress integration

The Flex 3 framework provides a way to support deep linking and search engine optimization (SEO) in the BrowserManager class. However, they require that you use specific HTML templates.

This package makes it possible to use the BrowserManager with applications embedded with SWFObject using SWFAddress as history manager instead.

Update: As of v2.1, SWFAddress will automatically integrate with Google Analytics, if it's available. This means you can get deep linking and Analytics tracking into your Flex application with minimal effort. v2.0 of SWFAddress can also be made to integrate with Analytics, but in v2.1 it just works.

Usage

Download the SWC (there is a download link to the right) and make sure it is in your project's search path. Also make sure that the embedding HTML page loads SWFAddress.

In your Flex application the only thing you need to do is this:

SWFAddressBrowserHistory.install();

After that you can use the BrowserManager in the same way you would with Adobe's HTML templates (you can find instructions in Flex 3 Developer's Guide, Chapter 34). Here is a very simple example:

private function onCreationComplete( event : Event ) : void {
  SWFAddressBrowserHistory.install();

  // 'browserManager' is an instance variable
  browserManager = BrowserManager.getInstance();

  browserManager.addEventListener(
    BrowserChangeEvent.BROWSER_URL_CHANGE,
    onBrowserUrlChanged
  ); 

  browserManager.init("", "My deep linkable application");
}

private function onBrowserUrlChanged( event : Event ) : void {
  trace("The user navigated to: " + browserManager.fragment);
}
						

Explanation

The call to install creates the JavaScript needed to communicate with the BrowserHistory class. The actual JavaScript code is embedded in the SWFAddressBrowserHistory class, a somewhat unorthodox method perhaps, but one I think is worth a try as it means that there is one less dependency and simpler deployment -- the JavaScript doesn't have to be uploaded to the server, or included on the embedding page. I've discussed this method here: Abusing the ExternalInterface, if you're interested.

The JavaScript that communicates with BrowserManager is quite simple and could easily be made to work with any other deep linking solution. You can look through the code for BrowserManager in the Flex 3 framework if you're interested, or you can mail me and ask.

A side benefit from using this package is that you can use SWFAddress' excellent browser support in Flex without having to use it's ugly ActionScript 3 interface.

License

It's Freeware, and if you really really want you can have the code, but it's nothing fancy.

Changelog

Dates are on the format YYYY-MM-DD.

2007-12-28
  • Initial version