我试图编写一个类,它将返回给定字符串的 json 对象。我知道下面代码的语法是完全错误的,但只是尝试这样做。
package com
{
import flash.display.MovieClip;
import com.adobe.*;
import com.adobe.serialization.json.JSON;
import flash.net.dns.AAAARecord;
import flash.net.URLRequest;
import flash.events.Event;
public class getJson extends MovieClip
{
public function getJson(urlString:String):Object
{
// constructor code
var returnObject:Object = new Object();
var urlLoader:URLLoader = new URLLoader();
returnObject=urlLoader.addEventListener(Event.COMPLETE,loadingComplete);
urlLoader.load(new URLRequest(urlString));
return returnObject;
}
private function loadingcomplete(e:Event):Object
{
var jsonObject:Object = new Object();
jsonObject=JSON.decode(urlString);
return jsonObject;
}
}
}