PDA

View Full Version : PHP to URLVariables


zero1
12-11-2007, 05:03 PM
I was able to provide a loader.data of arr[1]=one&arr[2]=two&arr[3]=three&counter=3 from PHP.

I can retrieve the value of the "counter" variable using...
var loader:URLLoader = URLLoader(event.target);
var vars:URLVariables = new URLVariables(loader.data);
my_txt.text = vars.counter;

But it don't work for "arr[1], arr[2], arr[3]"...
my_txt.text = vars.arr[1];

How do I use the variables from URLVariables in a looping statement?

panel
12-11-2007, 05:11 PM
firts you have to wait for data load


...
urlLoader.addEventListener(Event.COMPLETE, onComplette)
private function onComplette(evt:Event):void
{
trace(evt.target.data)
}

zero1
12-11-2007, 10:32 PM
Yeah, I've already done that. I'm already in the context of parsing the variables.

The "counter=3" is the last one my PHP would print.
<?
print "arr[1]=one";
print "&arr[2]=two";
print "&arr[3]=three";
print "&counter=3";
?>

With this...
var loader:URLLoader = URLLoader(event.target);
my_txt.text = loader.data;
I can see my loader.data having complete data in my_text textbox:
arr[1]=one&arr[2]=two&arr[3]=three&counter=3

But I can't access the arr[x]s...
var vars:URLVariables = new URLVariables(loader.data);
my_txt.text = vars.counter;
my_txt1.text = vars.arr[1];
my_txt2.text = vars.arr[2];
my_txt3.text = vars.arr[3];

I can output data if I instead use arr1, arr2, arr3 in PHP and in AS3.
var vars:URLVariables = new URLVariables(loader.data);
my_txt.text = vars.counter;
my_txt1.text = vars.arr1;
my_txt2.text = vars.arr2;
my_txt3.text = vars.arr3;

But how will I be able to use that in a looping statement? Is there such a thing as..
for(x=0;x<vars.counter;x++){
my_txt1.text = vars.arr + x;
}

theelephantwords
12-11-2007, 10:38 PM
this might work..


for(x=0;x<vars.counter;x++){
my_txt1.text = vars['arr'+x];
}