Simon_Weaver
Simon_Weaver

Reputation: 146208

Pass JSON to a Flash movie

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

Currently to communicate between javascript and Flash :

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

Upvotes: 6

Views: 6537

Answers (2)

James Hay
James Hay

Reputation: 12720

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.

Upvotes: 6

Adam Harte
Adam Harte

Reputation: 10530

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

It should point you in the right direction.

Upvotes: 1

Related Questions