I have two text fields. One is named txtFoo and the other is txtBar. They have numbers in them. When I click the btnSubmit I want the txtFoo.text and txtBar.text to be sent to a php file. Below is my code:
var variables:URLVariables=new URLVariables;
var varSend:URLRequest=new URLRequest("myURL.cgi");
varSend.method=URLRequestMethod.POST;
varSend.data=variables;
var varLoader:URLLoader=new URLLoader;
varLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE,completeHandler);
function completeHandler(evt:Event):void{
varLoader.load(varSend);
}
function submit(evt:MouseEvent):void{
variables.foo=txtFoo.text;
variables.bar=txtBar.text;
varLoader.load(varSend);
}
btnSubmit.addEventListener(MouseEvent.CLICK,submit);
I’m getting the error message below:
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()
at flash.net::URLLoader/onComplete()