I'm currently overseeing a project where our main application is being embedded into another web application. As part of this we needed to be able to pass information from an external source into our app, so we turned to Flash Vars. I'm not going to lie, it was a pain in the butt to figure out how to get them to work. I looked at a number of different examples, all of which failed, before I finally found one that steered me in the right direction, and even it had me doing edits in two or three places that were not necessary. In the end it was pretty simple (of course). Just open up your index.template.html for your application. You are going to edit the AC_FL_RunContent, but be careful because it's in two places, one for if the client didn't have the right flash player and one (the second one) for if they did. You need to edit this second one. Mine ended up looking something like this:
AC_FL_RunContent(
"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer",
"FlashVars", "MyToken="+token+"&a="+aVariable+"&b="+bVariable+""
);
Then to access the Flash Vars from Flex:
var paramObj:Object = Application.application.parameters;
var mapperToken:String = paramObj.MyToken;
var outsideA:String = paramObj.a;
var outsideB:String = paramObj.b;
And that was it. I of course check to make sure none of them are null etc. so that the application can still work stand alone. All in all it was a ton of ferreting around for the information and easy to do once I found this. Hope it helps someone else out.
No comments:
Post a Comment