[转] It's been a while since I have posted about anything. Truth be told its been a while since I've had 3 free minutes. I have been working on a fairly large project that has been rough in some respects but really great in others. The requirements for this project were pretty ambitious however allowed me to really get more involved with the much heavier side of Flash I haven't had much opportunity with (e.g. Remoting, Class based development, heavy server interaction etc..). During this project though (I'll post more information once its out of QA and gets launched) the issue of the back button was a big concern.
After a bit of digging however we were able to work through a solution that worked out pretty well. However it got me wondering why Macromedia didn't put a tad more effort into this feature/problem with recent Flash releases. I know they came out with the anchor option a while back, which is great if you have a very linear movie that isn't built in one frame. The anchor link "solution" just not a very practical feature. The oddest part however is that some of the "Industry Giants" have posted very good solutions that work (for most). Seems like it wouldn't be too hard to use Mike Chambers solution as a publishing template and native class inside Flash (especially considering he wrote this in July of 2002). I know this has been written about, blogged about, bitched about on countless websites, forums and client meetings but as long as the issue is outstanding I'm sure this will continue.
I also should say that I was always taught that if the user has to use the back button theres a problem with the UI...so fix the UI as opposed to hacking a solution to get the back button to do what you want. However I've been behind the glass in enough usability sessions to know that theres absolutely no way to predict what a user is going to do when given the keys to take your project for a ride. In any event I thought I'd pass along some resources and inspirational sites that I came across during my research, maybe it will save someone else some time down the road...until theres and actual fix and not just a work around.
Back Button Articles/tutorials:
Mike Chambers - Pet Store Example
Robert Penner Example
Justin Smith - Deep Stateful Linking and Back Button Integration
Chris Hendershot - Enabling a back button within flash
Kevin Newman - History Keeper
Mike Stenhouse - Fixing the Back Button and Enabling Bookmarking for AJAX Apps
A few sites with nice Back button / Deep Linking integration:
The Orange Project
Enlighten
Redbull Racing
Red Bull Track Attack
***** UPDATE 11/08/06 *****
Here are some links to a few more real solutions for the back button / deep linking question...
ex animo StateManager - http://exanimo.com/as2/statemanager
"Unlike all of the other solutions, the ex animo StateManager is the first method to be fully compatible with Safari. More importantly, though, it comes in a nice OO wrapper and is exceedingly easy to use. Since the class uses JSInterface (which at this point requires ExternalInterface), you’ll need to publish to at least Flash 8. However, this should change as work progresses on JSInterface.
It’s been tested successfully in IE5.5, IE6, FF 1.5.06, and Safari 2.0.4 but will degrade gracefully (i.e. behave like a normal flash page) in unsupported browsers.
Why should you use StateManager as a solution to your Flash back-button and deep-linking needs??
1. This is the first method that doesn't break in Safari when you navigate to a new page.
2. Unlike SWFAddress, is clean and Object Oriented (less ActionScript code required).
3. Thanks to JSInterface, you can import external JavaScript files directly from Flash.
4. While it integrates seamlessly with Geoff Stearn's SWFObject , it doesn't require that you use it. In fact, unlike SWFAddress, it degrades gracefully if JavaScript is turned off."
Asual SWFaddress - http://www.asual.com/swfaddress/
"SWFAddress is a small script that sits on top of SWFObject and provides deep linking for Flash websites and applications. In other words it enables the Back, Forward and Refresh buttons of the browser and creates unique URLs with page titles that can be sent over email or IM."
UrlKit - http://joeberkovitz.com/blog/urlkit
"URLKit is an open-source Flex library for browser URL control via deep linking which I [ Joe Berkovitz ] have developed in collaboration with Todd Rein of Adobe...
... Enter UrlKit, which adds URL-mapping or “bookmarking” capabilities to Flex-based RIAs. While numerous others have provided solutions to this problem, what’s different in UrlKit is that it leverages your existing application logic and provides a way to declaratively code the different URL states."
url message get:
import flash.external.*;
var curUrl:String = String( ExternalInterface.call(" function(){ return document.location.href.toString();}"));