JSON传递到Flash影片 [英] Pass JSON to a Flash movie
问题描述
什么是通过JSON和从Flash影片的最佳方法是什么?
What is the best way to pass JSON to and from a Flash movie?
目前通信JavaScript和Flash之间:
Currently to communicate between javascript and Flash :
- 在我使用Flash变量将数据传递到Flash影片时,它开始加载
- 在我使用'ExternalInterface的在运行时能够在运行时传递单个值,比如布尔
我想移动到一个新的水平,并为此与JSON了。
I want to move to the next level and do this with JSON now.
起初我只是想送JSON对实例的Flash影片的能力,但后来我将需要发送的数据来回。
Initially I just want the ability to send JSON to the flash movie on instantiation, but later i will need to send data back and forth.
我只想做正确的第一时间,避免任何兼容性或疑难杂症的问题,如果有任何。我不知道我是否能够通过整个对象到Flash,或者如果我需要把它作为原始JSON字符串序列化
I just want to do it right first time and avoid any compatibility or 'gotcha' issues if there are any. i dont even know if i can pass a whole object to Flash, or if i need to serialize it as a raw JSON string
推荐答案
由于TandemAdam指出,在他的链接,你将需要的的as3corelib ,它允许您访问的JSON类的静态方法JSON.deserialize()和JSON.serrialise()。
As TandemAdam pointed out in his link you will need the AS3Corelib, which gives you access to the JSON class with the static methods JSON.deserialize() and JSON.serrialise().
如果你只是使用JavaScript的网页上进行通信,那么你将不得不继续通过ExternalInterface的调用传递JSON字符串。
If you're just communicating with the JavaScript on the page then you will have to continue to pass the JSON strings through ExternalInterface calls.
如果您需要与服务器进行通信,你实际上可以直接将JSON字符串,并使用URLRequest对象和URLLoader对象的服务器。
If you need to communicate with a server you can actually send the JSON strings directly to and from the server using the URLRequest object and URLLoader object.
这篇关于JSON传递到Flash影片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!