Copy link to clipboard
Copied
Hi,
I have an application that requires me to pass data between ColdFusion 8.0.1 and Flex 4. My application takes the username of the currently logged in user (stored as a ColdFusion session variable) and passes it to Flex, which then passes the username into a CFC to retrieve the user's info to populate a Name/Address form. I've been trying to do this via a cfm wrapper file (instead of HTML) and flashvars, but regardless of what username I pass in, I always get the same user's information returned to the interface, almost as if the value is hard-coded somewhere in my Flex project. I am setting the flashvar value as:
<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 = {};
<cfoutput>
flashvars.userName = "#session.userName#";
</cfoutput>
(etc.)
Inside my mxml init() function, I am setting the local flex variable as:
private function init():void
{
private var userName:String = this.parameters.userName;
}
I had originally just hard-coded a value for userName when I was just testing the CF call Flex was making. Oddly, though, after I removed the hard-coded value and tried passing in the userName value from my cfm wrapper (quick note: I've tried passing in this value as both a session and a URL variable and have gotten the same results in both cases), the data returned is still the data associated with the previously hard-coded value. It's as if the Flex project itself is caching that value somewhere and keeps referring to it even though it's changed, but I have no idea if that's the case (or if it's even remotely possible, for that matter) or where I might look for it. I'm very new to Flex, so any help would be greatly appreciated. I've been using this article as a guide: http://www.adobe.com/devnet/flex/articles/fcf_deploying_flash.html; any better or other articles on this topic that might point me in the right direction are also appreciated.
Thanks in advance!
~ Amanda
Copy link to clipboard
Copied
Got it. Working code is:
in CFM wrapper:
var flashvars = {};
<cfoutput>
flashvars.userName = "#URL.userName#";
</cfoutput>
and in mxml file to loop through flashvars, find the userName and assign it to a local Flex variable:
private var userName:String;
private function init():void
{
for (var name:String in this.parameters)
{
switch(name)
{
case "userName":
userName = this.parameters[name].valueOf().toString();
break;
}
}
}
I'm using a switch statement so I can just go through and grab each flashvars value I'm setting as I find it. Hopefully this will help someone else out there who might be running into the same problem).