나는 이것이 매우 쉬운 일이지만 시간당 Google에서는 찾을 수 없다고 확신합니다. ActionScript를 처음 사용하여 .php 파일에 의해 생성 된 문자열에서 변수 배열을 가져 오려고합니다.URL 인코딩 문자열에서 배열 가져 오는 방법?
내 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.
};
}
난 당신이 이미 이해 생각하지만, 결국, 내가 배열을 갖고 싶어 (ActionScript에서) 나를 줄 것이다 :
the_array['var1']=42;
the_array['var2']=6;
the_array['var3']="string";
내가 도대체 뭘 잘못하고있는 겁니까? 어떻게해야합니까? 감사합니다.
편집 : PHP에서 PHP로 변수를 가져 오려고합니다. 예 : 내 PHP 파일을 제대로 HTML 쿼리를 배열을 변환하지만 ActionScript에서 배열을 구문 분석하는 방법을 모르겠습니다.
회신이 도움이 되었습니까? – silkfire