SWFAddress and Data Persistence

I'm creating a Flash site with a dynamic inventory search feature where a bunch of checkboxes toggle different types of clothing items to appear in a gallery. For example, users may check "Shirts" "Jeans" and "Bags" from the list and a dynamic array of images will be loaded in the gallery corresponding to their selections.

My problem is finding a way to save the state of the user's selections when they leave and return to the page.

If the site had a SUBMIT button for the user data, I would codify this into the URL with SWFAddress when the button was pressed (ie mysite.com/#/shirts-jeans-bags/) but since the client demands the checkboxes to show immediate results, I need a different approach. (Otherwise, every checkbox click would add to the user's SWFAddress history).

I want the site to preserve their data if the user were to navigate away from the page and then push the browser's Back Button.

Is this something I can do with SWFAddress? Better to use FlashVars? What's the best method to preserve the data?

Thanks! -B

Answers


You could call the flash movie from javascript onbeforeunload event. However, I think the most common approach is to reflect the current state of the selection in the URL. In your words, every checkbox click changes SWFAdress.

If you don´t like so many addresses in the SWFAddress history (let´s 5 different URLs after using the gallery filter 5 times) and you´d like the back button to go to a different section instead, you can always handle that in your SWF keeping track of the navigation (go to the previous page in history that is not the gallery).

I hope I helped.


Your best bet here is probably the SharedObject class. This is flash's version of cookies and lets you store data on the user's machine.

Other options are updating the url in response to any changes in the checkboxes, as you mention, or storing the state on the server for each user and updating when they make changes, but I think SharedObject is simpler and more appropriate.


Need Your Help

Best way to maintain a list of values in Java

java collections hashmap

I have a class that holds a list of connected clients, with their usernames being the key and the client instance being the value. So far the class looks like this:

How do I completely remove Visual Studio 11 Beta, before installing Visual Studio 2012?

visual-studio-2010 visual-studio visual-studio-2012

When I try to install VS2012, the installer suggests I should install it where the old VS11Beta was installed - and that tells me there's some leftovers from VS11Beta that needs to be cleaned.