PHP File:
echo("var1=".$region);
echo("var2=".$realm);
echo("var3=".$type);
echo("var4=".$teamName);
echo("var5=".$battlegroup);
AS3 File:
public function returnResult(e:Event):void{
var _string = unescape(e.target.data);
trace(_string);
if(count == 50){
trace(e.target.data.var1);
trace(e.target.data.var2);
trace(e.target.data.var3);
trace(e.target.data.var4);
trace(e.target.data.var5);
}
else{
count++;
}
}
Flash return:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
var1=euvar2=les-clairvoyantsvar3=5v5var4=wheres the dragonvar5=sturmangriff-charge
undefined
undefined
undefined
undefined
undefined
This should be a simple case of finding the variable’s by their names, but for some reason it’s not working.
Am I making a really stupid mistake here?
All you are getting back from the PHP is just a string (as you can see when you trace it). Just putting in “var=” doesn’t actually do anything that AS3 can understand – it’s still a string, the value of which happens to be “var=”. Since you are just dealing with a string, trying to access var1, var2 etc. properties will return undefined because a string has no such properties.
You can build in your own delimiter and split the string based on that, e.g. using the string “:::” as a delimiter between the different items in the string, and split the string into an array based on that. Alternatively, instead of just sending back unstructured text, you can send back structured XML and access properties that way.