Hello everyone,
I got a weird problem with onLoad for LoadVars. I have a dynamically generated movie clip which has a form. The form contains a button (movie clip) to send the stuff in the form to php. Here is the code first of all:
Flash:
in the very first frame there is a global variable, _global.testVariable which is set to be equal to “nothing”.
var messageVars = new LoadVars();
messageVars.mmID = this._parent.memberIDStorage.text;
messageVars.msgFrom = this._parent.fromText.text;
messageVars.msgTo = this._parent.toText.text;
messageVars.msgTitle = this._parent.titleText.text;
messageVars.msgContent = this._parent.messageText.text;
messageVars.sendAndLoad(‘message.php’, messageVars, ‘POST’);
messageVars.onLoad = function()
{
if(this.error != undefined)
{
_global.testVariable = this.error;
}
else
{
_global.testVariable = this.messageSend;
}
}
this._parent.testingText.text = _global.testVariable;
The PHP:
$membID = $HTTP_POST_VARS[‘mmID’];
$toWhom = $HTTP_POST_VARS[‘msgTo’];
$fromWhom = $HTTP_POST_VARS[‘msgFrom’];
$messageTitle = $HTTP_POST_VARS[‘msgTitle’];
$messageContent = $HTTP_POST_VARS[‘msgContent’];
print “messageSend=” . $membID . “|” . $toWhom . “|” . $fromWhom . “|” . $messageTitle . “|” . $messageContent;
The problem:
The problem is that when I click the button the first time the testingText textbox displays "nothing" as though the onLoad event was never called and the _global.testVariable has the same initial value. However, when I click the button the second time the testingText displays the right response (the code in PHP is obviously just to test that it got the variables).
I would guess that this has something to do with delay, but the strange thing is that PHP literally does nothing, and so it should be fast especially when all my other numerous PHP calls work flawlessly.
Does anyone have any suggestions about this?
Thanks ahead.
Sequence.