5 Replies Latest reply on Oct 17, 2006 2:45 PM by JennHysuick

    ColdFusion and Flex

    JennHysuick Level 1
      Ok - so I've spent months on this really cool Flex app, everything works to this point, and I know what I want to do next, but can't find anywhere on the net that will describe how to do it.

      I have a ColdFusion website, and one of the pages will serve up the lovely .swf all that i've made. The problem is: how to I pass variables from the ColdFusion site (because it knows who you are logged in as) to the Flex application (because it needs to write to a database based on who you are, but it doens't know who you are).

      At this point, I have two folders on my server - on for the coldfusion site, and one that I've developed my Flex app in, and I've been inserting the .swf file into my CF page, so it plays the movie, but I can't figure out how to pass a variable around.

      And, do all my .mxml and .as files need to be in the same directory as my CF pages for everyone to play nice?? I thought I had done so well to create the app, but now I don't know how to get it out to the people who need it!

      Thanks in advance (I have also posted this in the Flex forums, hoping someone somewhere will have an answer!)

        • 1. Re: ColdFusion and Flex
          Level 7
          There are many ways to do this. For one, you can use ColdFusion CFCs
          and Flex <mx:RemoteObject ...> to pass data back and forth. Is that
          enough of an idea for you, or do you need some more how to?

          I'm by no means an expert on my Flex and CF interactions yet. But I
          have built a small app that passes some data back and forth between my
          ColdFusion and Flex logic.
          • 2. Re: ColdFusion and Flex
            JennHysuick Level 1
            I'll need a bit more of an idea than that. I'm already using CFCs to talk to the database, but the CFCs used by my .mxml page are in a different location than the CFCs used by my cfm pages. And the .cfm pages have a variable value that I'd like to tell the .mxml page so that it can do queries based on the value (the CFCs don't know this value yet because it's two sets of CFCs that I'm working with).
            This all just seems so confusing to me right now - two working pages, but I need them to become one.

            Thanks for your help!
            • 3. Re: ColdFusion and Flex
              Level 7
              This all just seems so confusing to me right now - two working pages,
              but I need them to become one.

              Thanks for your help!

              I would guess that you do need to get the two pages working from one
              backend set of CFCs, even though those CFCs do not need to all live in
              one location, but that is probably the easiest to manage.

              You may need to make your CFM front end use some CFCs for the data
              abstraction that the flex can then also make use of.

              I would also speculate that Flex can make some use of URL parameters,
              but I have never done this. And I do not know if this would really help

              • 4. Re: ColdFusion and Flex
                Iceborer Level 1
                Jenn, I may be misreading this, but it seems you want to pass CF variable information in the Flex .swf. If so, the easiest way is to pass the CF values as FlashVars. I have a custom wrapper I'm working on to integrate Flex apps with some CF apps I'm currently running. I use an object to create a string variable (request.flashVars) that I pass to the call to run the swf (AC_FL_RunContent).

                Flashvars need to be passed as a string that looks like "name1=value1&name2=value2..." The variable name and value need to be URL encoded and the ampersand is used to separate name/value pairs.

                Hope this helps.
                • 5. Re: ColdFusion and Flex
                  JennHysuick Level 1
                  Thanks for your help - FlashVars were the answer! What I did was insert a .swf object, and used the params
                  <param name="FlashVars" value="NAME=<cfoutput>#value#</cfoutput>" />

                  and on the Flex side, i put initialize="setvars()" in the application tag at the top, and then created
                  public function setvars():void
                  var name:string=Application.application.parameters.NAME

                  and it all just kinda worked...I'm sure there is more to this than just what I've done, but for what I needed, this will do the trick.