关于在 Flex 2 , ActionScript 3中使用 JSON

本文是对 Mike Chambers 的 Tutorial : Using JSON with Flex 2 and ActionScript 3  的简单介绍。

 

 

What is JSON you ask? From the JSON website:

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

什么是JSON呢,在JSON 官方站点的给出答案是:JavaScript Object Notation。一个方便数据转换的语言。如果我们要在网上传输数据,在不同类的接口间起桥梁的就是JSON,现在随着AJAX应用大幅被应用在网页上。

Mike Chambers 的文章比较长,鉴于他是三月末写的,那时的测试播放器是8.5,所以我给出调试范例的过程,而具体代码 Mike 讲的很具体了,我就不用特意翻译了,大家认真研究下吧。

调试过程:
1 你需要先有Flex2 SDK (如果有 Flex Builder 2也行因为它包括了SDK,但由于大家都是穷人,用免费的SDK调试的人一定很多,所以我介绍用SDK的调试方法)。 Flex2 SDK在我的文章里有下载

2 你需要下载好 corelib : http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries

3 解压下好的文件
例如我解Flex2 SDK到 G:\Flex2sdk\
到corelib的bin目录里,把corelib.swc放到G:\Flex2sdk\frameworks\libs\里
    SWC是经过编译后的库文件,放在你的类库目录里就能在编译时找到类了。
到corelib的src\trunk\src\actionscript3目录里,剪切com文件夹到G:\flex2\frameworks\source\里
    这些代码是编译SWC用的,由于已经已经编译好了类库文件,所以我们只是放到那里以备后用。
到corelib的src\trunk\examples\JSONExample目录里,剪切JSONExample.mxml文件到G:\Flex2sdk\bin里
    文件弄到那里都随便你,我为了讲解方便把他放到了和编译器相同的目录里

4 开始编译
开始菜单,进入运行,输入cmd
在命令行里进入G:\Flex2sdk\bin\
输入 mxmlc jsonexample.mxml就可以了

编译其他方式还有:
A:可以拖动该文件到mxmlc.exe上
B:可以自己写一个批处理文件。

编译完后,点击SWF文件就可以看到效果了,如果不行,请到SDK文件夹里的player里安装调试用播放器(v 9.0)

PS:在开源类库corelib里有以前梦寐以求的功能,大体列举如下:
com.adobe.crypto   com.adobe.errors   com.adobe.net   com.adobe.serialization.json   com.adobe.utils   com.adobe.webapis   com.adobe.webapis.events

com.adobe.crypto包里有md5,sha1,token加密类,
com.adobe.serialization.json包就是本文演示的JSON类
com.adobe.utils有很多使用的类ArrayUtil等。。。

转自:http://quantumflash.blog.hexun.com/4565041_d.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

游鱼_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值