2 Replies Latest reply on May 30, 2006 7:09 AM by jkgiven

    cfquery results into flash

    jkgiven Level 1
      First let me say that actionscript is brand new to me.
      Second let me say I have looked at numerous tutorials, explantions and so forth and have found them all to be lacking.
      Anyway...
      I just want to run a simple query against a DB and return the values to a flash file (for testing/learning purposes, I only have one record currently in the DB).
      The fields in the DB are id, firstName, lastName, and emailAddress
      I have four dynamic text instances in the flash movie each with the Var equaling a field in the DB.
      I tested the CFM file (get.cfm) to make sure it was returning the correct variable results (it was). I then added the "&" as needed to pass things to flash.

      Actionscript code in frame one of my movie:
      loadVariables("get.cfm", _root);

      Code from get.cfm
      <cfquery name="results" datasource="devKevin">
      SELECT * FROM FlashTest
      </cfquery>

      <cfoutput query="results">
      &id=#id#
      &firstName=#firstName#
      &lastName=#lastName#
      &emailAddress=#emailAddress#
      </cfoutput>

      But instead of getting id = 1, firstName=Kevin etc. I get id = #id# firstName=#firstName# etc.

      what am I doing wrong?
        • 1. Re: cfquery results into flash
          Level 7
          I would do it with the LoadVars class instead, and the .text property of
          your text boxes. Take away the "Var" properties and give the text boxes
          instance names of "id_txt", "firstName_txt", "lastName_txt" and
          "emailAddress_txt". And maybe also make a textfield with instance name
          "error_txt". Then use this code on a frame in your FLA:

          var receiver_lv:LoadVars = new LoadVars();
          receiver_lv.onLoad = function(success:Boolean) {
          if (success) {
          id_txt.text = receiver_lv.id;
          firstName_txt.text = receiver_lv.firstName;
          lastName_txt.text = receiver_lv.lastName;
          emailAddress_txt.text = receiver_lv.emailAddress;
          } else {
          error_txt.text = "Error Parsing or Loading File";
          }
          };
          receiver_lv.load("test_receiver.cfm");

          That usually works for me...



          jkgiven wrote:
          > First let me say that actionscript is brand new to me.
          > Second let me say I have looked at numerous tutorials, explantions and so
          > forth and have found them all to be lacking.
          > Anyway...
          > I just want to run a simple query against a DB and return the values to a
          > flash file (for testing/learning purposes, I only have one record currently in
          > the DB).
          > The fields in the DB are id, firstName, lastName, and emailAddress
          > I have four dynamic text instances in the flash movie each with the Var
          > equaling a field in the DB.
          > I tested the CFM file (get.cfm) to make sure it was returning the correct
          > variable results (it was). I then added the "&" as needed to pass things to
          > flash.
          >
          > Actionscript code in frame one of my movie:
          > loadVariables("get.cfm", _root);
          >
          > Code from get.cfm
          > <cfquery name="results" datasource="devKevin">
          > SELECT * FROM FlashTest
          > </cfquery>
          >
          > <cfoutput query="results">
          > &id=#id#
          > &firstName=#firstName#
          > &lastName=#lastName#
          > &emailAddress=#emailAddress#
          > </cfoutput>
          >
          > But instead of getting id = 1, firstName=Kevin etc. I get id = #id#
          > firstName=#firstName# etc.
          >
          > what am I doing wrong?
          >
          • 2. Re: cfquery results into flash
            jkgiven Level 1
            I'll give this a try - thanks for the help