Actionscript 3 GET/POST 到具有内容类型定义的服务器

Actionscripts 3 GET/POST to server with content type defination

我需要获取和发送请求 from/to 服务器。我在这个网站上找到了一个代码,但它对我不起作用。 api url 是真的,我可以从 firefox 获取数据“{"out":355}”。

import com.adobe.serialization.json.JSON;

var request:URLRequest=new URLRequest();
request.url="******************************************"
request.requestHeaders=[new URLRequestHeader("Content-Type", "application/json")];
request.method=URLRequestMethod.GET;
var loader:URLLoader=new URLLoader();
loader.addEventListener(Event.COMPLETE, receive);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, notAllowed);
loader.addEventListener(IOErrorEvent.IO_ERROR, notFound);
loader.load(request);

function receive(event:Event):void
{
    var myResults=JSON.decode(event.target.data);
    trace(myResults);
}

错误:

Scene 1, Layer 'MAIN PAGE', Frame 1, Line 15, Column 25 1061: Call to a possibly undefined method decode through a reference with static type Class.

import com.adobe.serialization.json.JSON;

var request:URLRequest=new URLRequest();
request.url="******************************************"
request.requestHeaders=[new URLRequestHeader("Content-Type", "application/json")];
request.method=URLRequestMethod.GET;
var loader:URLLoader=new URLLoader();
loader.addEventListener(Event.COMPLETE, receive);
loader.load(request);

function receive(event:Event):void
{
    trace(event.target.data);
    var json: Object = JSON.parse(event.target.data);
    trace("json.out = ", json.out);
}

结果:

{"out":352}

json.out = 352