Pass JSON to a Flash movie

旧街凉风 提交于 2019-12-06 03:25:08

问题


What is the best way to pass JSON to and from a Flash movie?

Currently to communicate between javascript and Flash :

  • I'm using 'flashvars' to pass data to the flash movie when it initially loads
  • I'm using 'ExternalInterface' at runtime to transfer single values, such as booleans at runtime

I want to move to the next level and do this with JSON now.

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.

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


回答1:


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().

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.

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.




回答2:


This post should be helpful to you: ThanksMister - JSON (Lite)

It should point you in the right direction.



来源:https://stackoverflow.com/questions/1096188/pass-json-to-a-flash-movie

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