Is it possible to pass native JavaScript objects such as arrays and hash-map-like objects to Flash Player with SWFObject?
I basically need to pass an array of objects to Flash from JavaScript in the Flash variables, so this is my code:
swfobject.embedSWF("application.swf", "divvy" "100%", "100%", null,
{ 'info': [
{ 'id': 1, 'name': "Hello, John" },
{ 'id': 2, 'name': "Hello, Dave" }
}]);
When I get the object in Flex, I simply get a String that looks like this: “[Object object], [Object object]” which leads me to believe that my array is being serialized into a String before entering Flash. Is there any known workaround?
And yes, I do need to pass Flash variables in this manner, since they’ll key off some loading which is necessary to do before the application starts.
Answer: as @Robusto mentioned above it is not possible to pass native JavaScript objects to Flash Player via Flashvars. I forgot that Flash variables are simply GET parameters to the SWF, nothing more. Thus,
application.swf?r=123is the same thing asswfobject.embedSWF('application.swf', '100%', '100%', null, {'r': 123}, null);I’ll probably just load some XML or something.