3 Replies Latest reply on Mar 7, 2007 4:03 AM by phil ashby

    Saving a movie's state

      I'm working on a site with a search tool built in flash. It pulls in data from xml files to populate three different list columns. I would like flash to remember where the user was browsing so that they don't have to click through all three columns when they hit the back button on a browser. I have flash sending out variables to php which in turn writes the variables back into the flash movie. It works well except for the broswer's back button. Because the cached page doesn't reload, everything is stuck as it was before. If you click refresh, the variables kick in and the flash movie goes to the correct location.

      Here is the search tool running on my test server (Scroll down to the column thing)

      Click on show all tab at the top of the tool, navigate to any product, click the broswers back button and then click refresh to see what I'm talking about. Is there any way to get this to work in flash? Can flash create its own session variables? Does anyone have a straw for me to grasp?

      I have tried Meta tags, writing the data to global variables and file includes. I have detirmined that I can't force the browser to reload the page. Can I get flash to take care of the problem internally?

      Thanks for you help.
        • 1. Re: Saving a movie's state
          phil ashby
          I think you can do it using a sharedObject.

          Let's say that your three listboxes are list1, list2, list3

          first thing to do is check to see if they have been to the site before by checking to see if a sharedObject exists already

          // so_history is the sharedobject that contains our data
          SO_history= SharedObject.getLocal("mysharedobject");
          // historyData is an array of the users history
          historyData = SO_history.data.historyData;

          if(historyData == undefined)
          //create empty
          historyData = new Array()
          // populate list 1 and select index # based on historyData[0]
          // based on selected data, populate list 2 and select index historyData[1]
          // based on selected data in 2, get list 3


          that deals with the refresh, but when you change the lists have an onchange handler that does something like this

          function list1changehandler()
          // update the array with the selected index
          historyData[0] = list1.selectedIndex
          // and then write/update the shared object
          SO_history = SharedObject.getLocal("mysharedobject");
          delete SO_history


          hope that helps!
          • 2. Re: Saving a movie's state
            toomanydaves Level 1
            I had no idea that sharedObjects could do that.
            Thank you so much Phil. Case closed, project done.
            You're a life saver.
            • 3. Re: Saving a movie's state
              phil ashby Level 1

              I've built a dynamic online course application that records the progress the user has made using this technique. When they return to the course it asks them if they want continue from where they left off or start from scratch. very useful!