AS3和JSON:错误1061 [英] AS3 and JSON : error 1061

查看:423
本文介绍了AS3和JSON:错误1061的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了几个小时一个可能是愚蠢的相对JSON编码的FLASH问题各地。

I spent hours around a possibly stupid problem relative to JSON encoding in FLASH.

我尝试做一些很简单:我做一个对象,我希望它在JSON序列化

I Try to do something very simple : I make an object and I want it to be serialized in JSON.

但Flash告诉我,

> 1061: Call to a possibly undefined method encode through a reference with static type Class.

下面是我的code。这是本教程这里的副本。什么是错在它(不是在教程中,我想,在我的code),但我想不出有什么可以是:

Here is my code. It's a copy of the tutorial here. Something is wrong in it (not in the tutorial I guess, in my code) but I can't figure out what is can be :

import com.adobe.serialization.json.JSON;

var member1:Object = new Object();
member1.firstName = "John"
member1.lastName = "Parker"
member1.age = "32"
member1.country = "Canada"
member1.job = "Programmer"

var member2:Object = new Object();
member2.firstName = "Peter"
member2.lastName = "Anderson"
member2.age = "30"
member2.country = "USA"
member2.job = "System administrator"

var myData:Object = {staff:[member1, member2]};

var myJson:String = JSON.encode(myData);

trace(myJson);

目前该行VAR myJson:字符串= JSON.en code(myData的);闪光灯产生上面提到的错误。 让我precise该类JSON是很好的地方那一定是(MY_PROJECT / COM /土坯/串行/ JSON / JSON.as),而且我可以找到它的EN code静态方法。

At the line var myJson:String = JSON.encode(myData); flash generate the error mentioned above. Let me precise that the class JSON is well where it has to be (my_project/com/adobe/serialization/json/JSON.as ) and that I can find the encode static method in it.

谁能告诉我在哪里,我的错误(s)是或有? 谢谢你。

Can someone tell me where my mistake(s) is or are ? Thank you.

推荐答案

JSON.parse JSON.stringfy 是您正在寻找在Flash Player 11 +的方法。

JSON.parse and JSON.stringfy are the methods you are looking for in Flash Player 11+.

JSON.en code JSON.de code 是土坯AS3的一部分LIB但由于Flash播放器有一个本地JSON解析器现在你不需要这个类。

JSON.encode and JSON.decode were part of the Adobe AS3 lib but since the Flash Player has a native JSON parser now you don't need that class.

这篇关于AS3和JSON:错误1061的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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