【发布时间】:2013-05-08 13:45:03
【问题描述】:
我确信这是一件非常容易的事情,但我在谷歌上几个小时都找不到它。 我是 ActionScript 的新手,我正在尝试从 .php 文件生成的字符串中获取变量数组。
我的 php 文件输出如下:
var1=42&var2=6&var3=string
我的 ActionScript 代码是:
public function CallAjax_VARIABLES(url:String , the_array:Array)
{
var request:URLRequest = new URLRequest(url);
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, VARIABLES_Complete_Handler(the_array));
try
{
variables.load(request);
}
catch (error:Error)
{
trace("Unable to load URL: " + error);
}
}
function VARIABLES_Complete_Handler(the_array:Array):Function {
return function(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
//the_array = loader.data; // this doesn't work.
//the_array = URLVariables.decode(loader); // this doesn't work either.
//trace(loader.data['var1']); // this outputs 42, so I'm getting the string from php.
};
}
我想你已经理解了这一点,但最后,我想要一个数组(In ActionScript),它会给我:
the_array['var1']=42;
the_array['var2']=6;
the_array['var3']="string";
我做错了什么?我该怎么办? 谢谢!
编辑: 我正在尝试从 php 到 ActionScript 获取变量。 例如我的 PHP 文件正确地将数组转换为 html 查询,但我不知道如何在 ActionScript 的数组中解析它们。
【问题讨论】:
-
我的回复对您有帮助吗?
标签: php arrays actionscript-3 urlvariables