I’ve been working on a project recently and it came time to add deep linking. I looked into Adobe’s Browser Manager class and found an amazing API for deep linking but I wanted it in MXML. So I added a few features and wrapped up the behavior so it only takes about one line of code to add deep linking to your app. Well, sortof. Anyway, here it is.
At the minimum all you have to add is this:
The Link Manager automatically adds links in the browser as you move through the states in your application. It also “reads” the url when the page loads in the browser and automatically moves the application to that state.
Every time the state changes it updates and “writes” the project name and current state to the browser title and then writes the permanent link to the browser address bar.
All you need to do is to add the link manager to the application. You do not need to specify any parameters although additional options are available.
If you want to modify what is written to the browser address bar you can use the writeLinkFunction.
If you want to modify the application when you “read” the url in the address bar you can use the readLinkFunction and perform additional actions and/or redirect to a different state.
If the url contains incorrect data, ie if it points to a non existant state. You can use the stateNotFound property to send the user to a “state not found” state.
You can get the source by right clicking on the links. I’ve also uploaded it to an SVN repository, http://www.assembla.com/wiki/show/flexcapacitor getting the most recent version and contributors. Note: If you’ve read that page you’ll know I have a couple of announcements coming up. BTW the license for the Link Manager is MIT (free for commercial use).