Hopefully this is a relatively easy one! I’m using the following code to obtain some variables from a remote page:
public function URLLoaderDataFormatExample(event:MouseEvent)
{
var request:URLRequest = new URLRequest("http://www.<mydomain>/sample.txt");
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
{
variables.load(request);
}
catch (error:Error)
{
trace("Unable to load URL: " + error);
}
}
private function completeHandler(ev:Event){
var loader = URLLoader(ev.target);
trace(loader.data.st);
}
This works fine, until I change sample.txt to sample.php and use echo to print out my name variable pair. I get the following error with the PHP file:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
My PHP code is simply: echo “?st=OK”;
What’s going wrong?
Cheers
Kevin