Transfer JSON to a Flash Movie

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

Currently for communication between javascript and Flash:

  • I use flashvars to transfer data to a flash movie when it initially loads
  • I use 'ExternalInterface' at runtime to pass single values ​​like booleans at runtime

I want to go to the next level and do it using JSON.

Initially, I just want the ability to send JSON to the flash movie when creating the instance, but later I will need to send the data back and forth.

I just want to do it right the first time and avoid any compatibility issues or "gotcha" if any. I don’t even know if I can pass the whole Flash object, or if I need to serialize it as a JSON string with cheese

+5
source share
2 answers

As TandemAdam pointed out in his link, you will need AS3Corelib , which gives you access to the JSON class with the static methods JSON.deserialize () and JSON.serrialise ().

If you just communicate with JavaScript on the page, you will have to continue to pass JSON strings through ExternalInterface calls.

, JSON URLRequest URLLoader.

+5

All Articles