在ActionScript 2发送JSON [英] Sending JSON in ActionScript 2

查看:339
本文介绍了在ActionScript 2发送JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁知道如何在ActionScript 2发送JSON?

anyone know how to send JSON in ActionScript 2?

我尝试使用XML(),但它改变了所有入"发送前例:

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"}

也不能升级到AS3(希望我能)

also cannot upgrade to AS3 (wish i could)

推荐答案

下面是你如何做到这一点

Here's how you do it

创建扩展的LoadVars一个新的类,并覆盖的toString方法返回的JSON。然后,您可以使用load()和sendAndLoad()发送JSON到一个网址

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

例如:

class SendJson extends LoadVars {

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

   public function toString() {
      return data;
   }

}

这篇关于在ActionScript 2发送JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆