Reputation: 16558
I'm wondering if JavaScript can post JSON messages to Flash? and if so can you please provide an example or a link to one?
Upvotes: 1
Views: 362
Reputation: 132138
Use ExternalInterface class to add callback methods that Javascript can call.
for example:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("callbackName", doMyCallback);
function doMyCallback(someParam:Strimg):void {
// use the AS3CoreLib JSON decoder like mentioned by @ludesign to decode the JSON string.
}
Then in your javascript, you can call the callbackName method on the flash object.
Upvotes: 3
Reputation: 4211
I am pretty sure that you can use FlashVars for this. Been a long time since I have done it so I wouldnt be able to provide code but a quick google found a couple of links:
http://kb2.adobe.com/cps/164/tn_16417.html
http://www.permadi.com/tutorial/flashVars/index.html
Hope it helps.
Upvotes: -1