Skip to main content
Known Participant
June 20, 2006
Question

why do I have to press button twice?

  • June 20, 2006
  • 5 replies
  • 609 views
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
This topic has been closed for replies.

5 replies

timdiaconAuthor
Known Participant
June 23, 2006
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.
timdiaconAuthor
Known Participant
June 23, 2006
David,

Sorry forgot to mention I am aware of the internet exporer issue on PC's, I am using safari on a mac?
timdiaconAuthor
Known Participant
June 23, 2006
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?
Inspiring
June 20, 2006
>> 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."


Inspiring
June 20, 2006
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.