sendAndLoad?

What is the correct way to refer to variables returned in a sendAndLoad operation? Php is returning a name=value& string which is being passed back into a LoadVars object called rtnVars. How should I then refer to the values to update the value of a text field?
Thanks
Mark
:-\

well, it loads it back into the LoadVars object (unless you specified another object to load it to)
anyways, to refer to it simply use myLoadVars.name, i.e:

myTextField.text = myLoadVars.name;

Well that is what I thought but I can’t populate the text field. In this example I have used a different LoadVars object to receive the reply. My php script returns simply lastName=Smith. I’ve tested this in a browser.

Here’s the actionscript:-

// ActionScript Document
function dataLoad(){
//will post data eventually but not for testing
lvAddressData.sendAndLoad(“hotels.php”, rtnVars, “POST”);
myTextField.text = rtnVars.lastName
}

//Run starts here
lvAddressData = new LoadVars();
rtnVars = new LoadVars();
dataLoad()

The text field has an instance name of myTextField. Should this be variable name instead. I have seen both methods mentioned. What is the difference?

Thanks, Mark

ahh, you need to wait for the data to actually load before you can populate it. something like this:

function dataLoad() {
  lvAddressData.onLoad = dataRecieved;
  lvAddressData.sendAndLoad("hotels.php", rtnVars, "POST");
}
function dataRecieved(success) {
  if (success) {
    myTextField.text = rtnVars.lastName;
  } else trace("Failed!");
}
lvAddressData = new LoadVars();
rtnVars = new LoadVars();
dataLoad();

I think we are getting somewhere, but I get the “Failed” trace.

My text field is set up as Dynamic Text and has instance name of myTextField. My php script returns lastName=Smith
Any more ideas?

What is the “success” passed to dataReceived??

from the AS Dictionary:

Usage

myLoadVars.onLoad(success)

Parameters

success The parameter indicates whether the load operation ended in success (true) or failure (false).

for some reason its failing to send/load the data. im not sure why.

Should my text field have an instance name or variable name??

well, using this code, instance name.

but that shouldn’t cause the LoadVars object to fail! try removing that ‘if’ and see if that works. make sure the URL you’re accessing actually works, and stuff like that.