问题描述
我有这个Flash code。它发出的积分和用户名在我的比赛中savescores.php。但我有上述错误。我已经改变URLLoaderDataForma.VARIABLES到文本,但还是同样的错误发生。我应该怎么做才能解决这个问题?在此先感谢。
私有函数SendScore(得分:INT)
{
VAR变量:使用URLVariables =新的URLVariables();
variables.score =得分;
variables.username =用户名;
VAR的URLLoader:的URLLoader =新的URLLoader();
VAR的URLRequest:的URLRequest =新的URLRequest('的http://本地主机:90 / savescores.php');
urlrequest.method = URLRequestMethod.POST;
请将URLRequest.data =变量;
urlloader.dataFormat = URLLoaderDataFormat.TEXT;
对URLLoader.load(的URLRequest);
urlloader.addEventListener(引发Event.COMPLETE,在completeHandler,假,0,真正的);
urlloader.addEventListener(IOErrorEvent.IO_ERROR,的ErrorHandler,假,0,真正的);
}
私有函数在completeHandler(五:事件)
{
VAR瓦尔:使用URLVariables =新的URLVariables(e.target.data);
如果(vars.success)跟踪(保存成功);
其他(保存失败);
}
私有函数的ErrorHandler(E:IOErrorEvent)
{
跟踪(发生错误);
}
我认为这个问题是不是与要求,但响应处理。您实例作为瓦尔的的URLVariables 的,但可能的 e.target.data em>的不符合预期的格式。跟踪的 e.target.data em>的值,以获得更多的信息。
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');
}
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.de code中的字符串必须是包含名称/值对的URL连接codeD查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!