4 Replies Latest reply on Mar 2, 2007 3:56 AM by maith

    How can I get web page to retain button count values

    maith Level 1
      Hi,
      I have a button which, each time it is pressed increments a number. The number is shown in a text box. This all works fine, on my web page. However if I close the web page and then reopen it, the count number goes back to zero. How can I keep the number it was (eg 10) and keep incrementing it ?
      I have the button on Frame 1 and the text box on Frame 2.

      Thanks,
      Paul
        • 1. Re: How can I get web page to retain button count values
          Level 7


          maith wrote:
          > Hi,
          > I have a button which, each time it is pressed increments a number. The
          > number is shown in a text box. This all works fine, on my web page. However if
          > I close the web page and then reopen it, the count number goes back to zero.
          > How can I keep the number it was (eg 10) and keep incrementing it ?
          > I have the button on Frame 1 and the text box on Frame 2.

          You will need to use Shared Object to store the info on user drive.
          It is Flash's native form of cookies and works locally (from exe projector)
          as well as in browser.


          --
          Best Regards

          Urami


          --

          !!!!!!! Merry Christmas !!!!!!!
          &
          Happy New Year


          <urami>
          If you want to mail me - DO NOT LAUGH AT MY ADDRESS
          </urami>
          • 2. Re: How can I get web page to retain button count values
            maith Level 1
            Thanks Urami,
            I will have a look at that.

            Paul
            • 3. Re: How can I get web page to retain button count values
              maith Level 1
              Hi again, I have a shared object which records the No. of times a button is pressed. However I want the shared object, to keep adding to the count, the next time the swf file is opened. At present it resets to 1, when the button is pressed again. How can I get the shared object to keep incrementing ?
              The code I have is:
              var my_so:SharedObject = SharedObject.getLocal("savedShare", "/");
              dir_btn.onRelease = function(){
              if (counter == undefined) {
              counter = 1;
              }
              else {
              var count =counter++;
              my_so.data.coun = count;
              my_so.flush();
              }
              myOBJ_txt.text = counter//holder;
              trace ("my_so.data.coun = " +my_so.data.coun);
              }
              trace ("count = " + count);
              //PLACE SHARED OBJECT COUNT IN A TEXT BOX
              so_txt.text = my_so.data.coun ;

              Thanks,
              Paul
              • 4. Re: How can I get web page to retain button count values
                maith Level 1
                Solved this myself. Far less complicated than I was trying. Hope this helps someone else.

                var my_so:SharedObject = SharedObject.getLocal("savedShare", "/");
                dir_btn.onRelease = function(){
                if (my_so.data.count == undefined) {
                my_so.data.count = 1;
                }
                else {
                my_so.data.count++;
                my_so.flush();
                }
                trace ("my_so.data.count = " +my_so.data.count);
                }
                so_txt.text = my_so.data.count ;

                Easy when you know how !