#2101:传递给 URLVariables.decode() 的字符串必须是包含名称/值对的 URL 编码查询字符串 [英] #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs

查看:30
本文介绍了#2101:传递给 URLVariables.decode() 的字符串必须是包含名称/值对的 URL 编码查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个闪存代码.它将我的游戏中的分数和用户名发送到 savescores.php.但我有上面的错误.我已将 URLLoaderDataForma.VARIABLES 更改为 TEXT 但仍然发生相同的错误.我应该怎么做才能解决这个问题?提前致谢..

I have this flash code. It sends score and username in my game to savescores.php. But I have the error above. I have changed URLLoaderDataForma.VARIABLES to TEXT but still same error occurs. What should i do to fix this problem? Thanks in advance..

private function SendScore(score:int) 
    {
        var variables:URLVariables = new URLVariables();
        variables.score = score;
        variables.username = username;
        var urlloader:URLLoader = new URLLoader();

        var urlrequest:URLRequest = new URLRequest('http://localhost:90/savescores.php');
        urlrequest.method = URLRequestMethod.POST;
        urlrequest.data = variables;
        urlloader.dataFormat = URLLoaderDataFormat.TEXT;

        urlloader.load(urlrequest);
        urlloader.addEventListener(Event.COMPLETE, CompleteHandler, false, 0, true);
        urlloader.addEventListener(IOErrorEvent.IO_ERROR , ErrorHandler, false, 0, true);
    }

    private function CompleteHandler(e:Event) 
    {
        var vars:URLVariables = new URLVariables(e.target.data);
        if(vars.success) trace('Saving succeeded');
        else ('Saving failed');
    }

    private function ErrorHandler(e:IOErrorEvent) 
    {
        trace('Error occured');
    }

推荐答案

我认为问题不在于请求,而在于响应处理.您将 var 实例化为 URLVariables,但可能 e.target.data 不符合预期的格式.跟踪 e.target.data 值以获取更多信息.

I assume that the problem is not with request, but with response handling. You are instantiating vars as URLVariables, but probably e.target.data does not comply with the format expected. Trace e.target.data value to get more information.

这篇关于#2101:传递给 URLVariables.decode() 的字符串必须是包含名称/值对的 URL 编码查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆