5 Replies Latest reply on Jun 23, 2006 3:42 AM by timdiacon

    why do I have to press button twice?

    timdiacon
      I've got a button on the stage with an instance name of "submit" I then have some action script like this...

      submit.onPress = function() {
      trace("do something");
      }

      Simple enough but the function isn't called when I first press the button however it is called when I press it for the second time. I've experienced this before and can't get to the bottom of it. Any ideas?

      Tim
        • 1. Re: why do I have to press button twice?
          DazFaz Level 1
          Through experience I have found its usally becuase you have a clash of actions. One script is trying to out run the other. A conflict of functions.
          • 2. Re: why do I have to press button twice?
            Level 7
            >> Simple enough but the function isn't called when I
            >> first press the button however it is called when I
            >> press it for the second time. I've experienced this
            >> before and can't get to the bottom of it.

            Are you seeing this while testing in Flash? Or does this only happen in
            Internet Explorer? If it's the latter, you may be seeing the result of
            Microsoft's recent changes to the way IE loads active content. Can you give
            us a bit more detail?


            David
            stiller (at) quip (dot) net
            Dev essays: http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: why do I have to press button twice?
              timdiacon Level 1
              Hello,

              OK so the function is just a simple sendAndLoad to a PHP script which inserts the data into a mySql table and then returns writing=Ok if there are no errors. Here is the action script...

              submit.onPress = function() {
              status.text = "Sending data...";
              mySaveData = new LoadVars();
              mySaveData.project = project.text;
              mySaveData.client = client.text;
              mySaveData.sendAndLoad("scripts/save_work_details.php", myLoadData, "GET");
              myLoadData.onLoad = function() {
              if (myLoadData.writing == "Ok") {
              feedback.text = "Details saved";
              submit._visible = false;
              } else {
              status.text = "Error in saving submitted data";
              }
              };
              };

              On the first click of the submit btn nothing happens then on the second click it works as expected. I have experienced this problem a lot and just cannot work out what is going on?
              • 4. Re: why do I have to press button twice?
                timdiacon Level 1
                David,

                Sorry forgot to mention I am aware of the internet exporer issue on PC's, I am using safari on a mac?
                • 5. Re: why do I have to press button twice?
                  timdiacon Level 1
                  AhHa I have fixed it!

                  Rewriting...

                  mySaveData = new LoadVars();

                  as...

                  var mySaveData:LoadVars = new LoadVars();

                  Seems to fix it incase anyone else has been experiencing simlar problems.