21.6. Integrating Flash with the Browser Back Button

Problem

You want your Flash application to work with the browser back button.

Solution

Use a frameset with a hidden SWF that uses LocalConnection to communicate with the main SWF.

Discussion

One of the major usability drawbacks with Flash in a web browser is that by default it doesn’t integrate with the browser back button. People are used to clicking the back button on the browser to navigate back through a web site or application. However, normally when a user clicks on the back button when a Flash application is running in the browser, it causes the browser to return to the HTML page that was open prior to the Flash application. Even if the user was navigating through the Flash application for the past hour, the default behavior of the back button causes the browser to jump out of the Flash application entirely. That can cause users to feel frustrated, particularly if the application doesn’t have a way of remembering the state, so that the user has to start over again when clicking the forward button to return to the Flash application.

Although there is a feature in Flash called Anchors that is supposed to correct the issue with the back button, the feature does not work with most browsers, and it appears to have been deprecated in Flash 8. However, with a little work, it is possible to build a Flash application that works with the browser back button in every browser. This approach requires the following:

  • A navigator .swf file and ...

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.