as3 php变量

时间:2012-05-17 09:38:25

标签: php actionscript-3

as3代码:

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输出

成功= 1&安培; registration_id = 1

错误是:

Error Image

1 个答案:

答案 0 :(得分:1)

使用TEXT格式代替VARIABLES

loader.dataFormat = URLLoaderDataFormat.TEXT;

以下是相关文档:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#dataFormat