Passing request data with Flashvars
cortlander1 Oct 29, 2010 8:09 AMI need to pass query parameters from one application to another and am following an example in help docs at
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf626ae-7feb.html
So I am passing parameters through the wrapper object as below:
<%
String userId = (String) request.getParameter("userId");
String authToken = (String) request.getParameter("authToken");
%>
...
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
var swfVersionStr = "10.0.0";
<!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
flashvars.userId = "<%= userId %>";
flashvars.authToken = "<%= authToken %>";
var params = {};
params.quality = "high";
params.bgcolor = "#869ca7";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "xacmlMain";
attributes.name = "xacmlMain";
attributes.align = "middle";
swfobject.embedSWF(
"main.swf", "flashContent",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
<!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>
In the mxml file:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mod="mod.*"
applicationComplete="readParams(event)"
layout="vertical" height="100%" width="100%">
...
protected function readParams(event:Event) : void {
var userId:String;
var authToken:String;
var subjectParams:Object = root.loaderInfo.parameters;
for (var subjectParam:String in subjectParams) {
userId = subjectParams["userId"];
authToken = subjectParams["authToken"];
}
//userId = root.loaderInfo.parameters.userId;
Alert.show ("\t" + "userId value" + ":\t" + userId + "\n" +
"\t" + "authToken value" + ":\t" + authToken + "\n" );
}
However, seems like this part of the code is not working:
flashvars.userId = "<%= userId %>";
flashvars.authToken = "<%= authToken %>";
because instead of the values passed these variables, my app reads
< userId
< authToken
if I use values which are fixed, it works fine e.g.
flashvars.userId = "smith";
Your help will be much appreciated
Thank you.

