我想从一个函数中获取一个变量到一个类中。
下面的代码是我的课,我想var.status
进入公共课。
package
{
public class GetJson
{
public var loader:URLLoader = new URLLoader();
public var status:String = "notlive"; // i want to get status var to here
public function GetJson()
{
var request:URLRequest = new URLRequest("http://myurl.com/json.json");
loader.load(request);
loader.addEventListener(Event.COMPLETE, jsonLoaded);
}
public function jsonLoaded(event:Event):void
{
var jsonContent:URLLoader = URLLoader(event.target);
var data:Object = JSON.parse(jsonContent.data);
var status = data[0].status; // This the variable that i want to get up there
trace(status);
return;
}
}
}