传给服务器JSON,和从服务器获取json

var loader:URLLoader = new URLLoader();

        var url:URLRequest = new URLRequest("http://localhost/Handler.ashx");
        url.method = URLRequestMethod.POST;
        var values:URLVariables = new URLVariables();
        var o:Object=new Object();
        o.uname="asd";
        o.age=111;
        values.message = JSON.encode(o);
        url.data = values;
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        loader.addEventListener(Event.COMPLETE,success);
        function success(e:Event):void
        {
            var l:URLLoader = e.target as URLLoader;
            var a:* = JSON.decode(l.data.ss);
            evt.target.parent.gotoAndPlay("registSuccess");
        }
        loader.load(url);

你可能感兴趣的:(json)