AS3 PHP变量
问题描述:
AS3 code:
public function exists(uid:String):void {
request = new URLRequest("http://localhost/index.php");
request.method = URLRequestMethod.POST;
variables = new URLVariables();
variables.uid = uid;
request.data = variables;
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, urlLoader_existsHandler);
loader.load(request);
}
protected function urlLoader_existsHandler(event:Event):void {
trace(event);
//var variables:URLVariables = URLLoader(event.target).data;
//trace(variables);
//trace(variables.success);
}
PHP输出
PHP output is
成功= 1&安培; registration_id = 1
success=1®istration_id=1
错误是:
答
使用变量的文本格式,而不是
Use the TEXT format instead of VARIABLES
loader.dataFormat = URLLoaderDataFormat.TEXT;
下面是有关文档:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#dataFormat