views:

15

answers:

2

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

A: 

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.

ozke
Is there a way to do that? I can skip all the gallery entries except the most recent one?
Brian Bird
Like Dane suggests, you could use SharedObject class, however, I would go with my suggested solution. The reason is, if I´m in a search where I´ve selected checkboxes A,B,E and I want to share the results with a different person, that´s pretty much the only way to go.
ozke
A: 

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.

Dane