Coldfusion MX7 desperate help: Flash remoting

Discussion in 'Programming' started by lespaul00, Jan 3, 2008.

  1. #1
    What I am using:

    Coldfusion MX7
    Dreamweaver 8
    Flash 8

    I have a recipes database. Ultimately, i'd like to create a flash application that displays a "recipe of the day" on my website. It would would start with record 1, and every day, increase by 1... I assume I can accomplish this with application variables (but I don't know much about this yet).

    I have a database set up, my website up, and everything is working. My next step is learning Flash remoting to be able to pull database data into my flash applications. So, I purchased Ben Forta's book "Macromedia COLDFUSION MX7 web application costruction kit" and i've tried for awhile to get an example in the book to work.

    I understand that there is an issue with the examples provided with the book since I am using Flash 8. I read many different solutions online, but I still cannot get this to work. Here is my flash actionscript (which I changed to ActionScript 2.0 in publish settings):

    
    import mx.remoting.NetServices;
    
    // uncomment this line when you want to use the NetConnect debugger
    // #include "NetDebug.as" 
    
    // --------------------------------------------------
    // Application initialization
    // --------------------------------------------------
    
    if (inited == null)
    {  
      // do this code only once
      inited = true;
      
       // set the default gateway URL (this is used only in authoring)
    NetServices.setDefaultGatewayUrl("http://localhost:8500/flashservices/gateway")
      
      // connect to the gateway
      gateway_conn = NetServices.createGatewayConnection();
      
      // get a reference to a service
      // In this case, the "service" is the /ows/23 directory in web server root
      myService = gateway_conn.getService("ows.23", this);
    }
    
    
    // --------------------------------------------------
    // Handlers for user interaction events
    // --------------------------------------------------
    
    // This gets called when the "SearchButton" button is clicked
    function SearchButton_Clicked ()
    {
      // ... put code here
      // For example, you could call the "bbbb" function of "my.service" by doing:
      // myService.bbbb(123, "abc");
    
      // In this case, we want to use the SimpleSearchProvider service function
      // (in other words, we want to execute SimpleSearchProvider.cfm)
      myService.SimpleSearchProvider({SearchString:MySearchString});
    }
    
    // --------------------------------------------------
    // Handlers for data coming in from server
    // --------------------------------------------------
    
    // This gets called with the results of calls to the server function "bbbb".
    function SimpleSearchProvider_Result ( result )
    { 
      // ... put code here
      // For example, if result is a RecordSet, display it in a ListBox by doing:
      // myListBox.setDataProvider(result);
    
      // In this case, we will simply set the SearchResults variable to whatever
      // was returned by ColdFusion.  Because the SearchResults variable is bound
      // to the multiline text box in the search UI, the result will display there
      SearchResults = result;
    }
    
    
    
    stop();
    Code (markup):
    I do not get errors, but when I try to use the simplesearchmovie.swf, it does not retrieve anything when I type a keyword.

    I think there's something wrong with the following line:
    NetServices.setDefaultGatewayUrl("http://localhost:8500/flashservices/gateway")
    Code (markup):
    I added the database to this directory:

    C:\CFusionMX7\wwwroot\ows\data

    And added it in CFMX7 administrator. It is now listed as OK.

    Also, here is the SimpleSearchProvider.cfm in the same folder:

    
    <!--- 
     Filename: SimpleSearchProvider.cfm
     Author: Nate Weiss (NMW)
     Purpose: Provides a simple film search service for a Flash MX movie
    --->
    
    <!--- We are expecting a SearchString parameter from Flash --->
    <cfparam name="FLASH.searchstring" type="string">
    
    <!--- Query the database for any matching film records --->
    <cfquery name="searchQuery" datasource="ows" maxrows="1">
     SELECT *
     FROM Films
     WHERE MovieTitle LIKE '%#FLASH.searchstring#%'
    </cfquery>
    
    <!--- Set the FLASH.Result variable to the summary of the returned film --->
    <!--- This will be available as the “result” variable in the --->
    <!--- SimpleSearchProvider_Result handler within the Flash movie --->
    <cfset FLASH.result = searchQuery.summary>
    Code (markup):
    Does anyone know what I am doing wrong here?
     
    lespaul00, Jan 3, 2008 IP