Sending JSON in ActionScript 2

别等时光非礼了梦想. 提交于 2019-12-08 10:23:33

问题


anyone know how to send JSON in ActionScript 2?

I tried using XML() but it changes all " into " before sending it. Ex:

var callout = new XML({ "name": "John"})
callout.sendAndLoad('http://api.app.com', new XML());

but what gets sent is { "name": "John"}

also cannot upgrade to AS3 (wish i could)


回答1:


Here's how you do it

Create a new class that extends LoadVars and override the "toString" method to return the JSON. You can then use load() and sendAndLoad() to send JSON to an URL

Example:

class SendJson extends LoadVars {

   public var data:String;  // Put your JSON here

   public function toString() {
      return data;
   }

}


来源:https://stackoverflow.com/questions/11234542/sending-json-in-actionscript-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!