Flash MX 2004 remoting: Works on localhost, but not on web server

Discussion in 'Graphics & Multimedia' started by lespaul00, Jan 7, 2008.

  1. #1
    Hello,

    I’ve been working on developing a remote widget using flash remoting to my coldfusion server. I’ve gotten it to work properly on my localhost (http://localhost:8500/) but it does not work when I upload it to my website (www.mywebsite.com for example). The .swf looks right when I access it from my website, but fails to pull the information in from my coldfusion server and display it. Any help is GREATLY appreciated… this has been a long struggle.

    For development, I am using:

    Flash MX 2004 Professional
    Dreamweaver 8
    Coldfusion MX7

    I took an example in Ben Forta’s book, Macromedia ColdFusion MX 7 Web Application Construction Kit, to use as a test for my flash remoting. As so, I have modified it a bit to suit my needs. I am simply having it retrieve and display an image and description (just for testing).

    Below is a breakdown of my codes, and the directory locations of each of the files.

    For localhost testing:

    MerchBrowser.fla is located in C:\CFusionMX7\mywebsite\remoting\
    MerchProviderCFC.cfc is located in C:\CFusionMX7\mywebsite\remoting\
    MerchDetailProvider.cfm is located in C:\CFusionMX7\mywebsite\remoting\
    MerchRecordsetProvider.cfm is located in C:\CFusionMX7\mywebsite\remoting\
    Mydatabase.mdb is located in C:\CFusionMX7\mywebsite\db\

    MerchBrowser.fla

    // Include support for Flash Remoting Components
    #include "NetServices.as"
    
    // uncomment this line when you want to use the NetConnect debugger
    // #include "NetDebug.as" 
    
    // --------------------------------------------------
    // Handlers for user interaction events
    // --------------------------------------------------
    
    // --------------------------------------------------
    // 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/26 directory in web server root
      myService = gateway_conn.getService("mywebsite.remoting.MerchProviderCFC", this);
    
      // Call the service function that fills the ListBox with a list 
      // of products (from ColdFusion) for the user to browse through
      myService.MerchDetailProvider();
    }
    
    // This function retrieves the detail information about the selected product.
    // It is executed when the last frame of the movie is reached
    // (when the detail view has finished hiding itself under the product list)
    
    
    // --------------------------------------------------
    // Handlers for data coming in from server
    // --------------------------------------------------
    
    // This executes when a merchandise detail record has been received
    function MerchDetailProvider_Result(result) {
      // The result variable is a recordset that contains just one row
      // The detailRecord variable will represent the row of data
      var detailRecord = result.getItemAt(0);
      
      // Display detail information in text boxes
    
      _root.DescriptionTextBox.text = detailRecord.MerchDescription;
    loadMovie("../images/" + detailRecord.ImageNameSmall, _root.ImageMovie);
    
      // If the ImageNameSmall column contains an image filename, display it
      
      // Now that the information about the merchandise has been placed,
      // make the display slide back into view, revealing the information
    
    }
    
    // Stop here, so animation doesn't occur until user selects a product
    stop();
    
    Code (markup):

    MerchProviderCFC.cfc

    <!--- 
     Filename: MerchProviderCFC.cfc
     Author: Nate Weiss (NMW)
     Purpose: Creates a ColdFusion Component that supplies data about products
    --->
    
    <cfcomponent hint="Provides data about merchandise records." output="false">
     
    
    <!--- merchDetailProvider() function --->
    <cffunction name="merchDetailProvider" returnType="query" access="remote"
     hint="Returns details about a particular item in the Merchandise table."
     output="false">
    
    
    	
    	<cfset var merchQuery = "">
    	
    	<!--- Query the database for merchandise records --->
    	<cfquery name="merchQuery" datasource=" Mydatabase.mdb" maxrows="1">
    	SELECT MerchID, MerchName, MerchDescription, ImageNameSmall, MerchPrice
    	FROM Merchandise 
    	WHERE MerchID = 12
    	</cfquery>
    	
    
    	
    	<!--- Return the query --->
    	<cfreturn merchQuery> 
     </cffunction>
    
    </cfcomponent>
    
    Code (markup):


    MerchDetailProvider.cfm

    <!--- 
     Filename: MerchDetailProvider.cfm
     Author: Nate Weiss (NMW)
     Purpose: Provides film detail to a Flash movie
    --->
    
    <!--- We are expecting a MerchID parameter to be passed from Flash --->
    
    
    <!--- Query the database for merchandise records --->
    <cfquery name="MerchQuery" datasource="Mydatabase.mdb">
     SELECT MerchID, MerchName, MerchDescription, ImageNameSmall, MerchPrice
     FROM Merchandise 
     WHERE MerchID = 12
    </cfquery>
    
    
    
    <!--- This will be available as the “result” variable in the --->
    <!--- MerchDetailProvider_Result handler within the Flash movie --->
    <cfset FLASH.result = merchQuery>
    
    Code (markup):


    MerchRecordsetProvider.cfm

    <!--- 
     Filename: MerchRecordsetProvider.cfm
     Author: Nate Weiss (NMW)
     Purpose: Provides data to a Flash MX movie
    --->
    
    <!--- Query the database for merchandise records --->
    <cfquery name="merchQuery" datasource="Mydatabase.mdb">
     SELECT MerchID, MerchName
     FROM Merchandise
     ORDER BY MerchName
    </cfquery>
    
    <!--- This will be available as the “result” variable in the --->
    <!--- MerchRecordsetProvider_Result handler within the Flash movie --->
    <cfset FLASH.result = merchQuery>
    
    Code (markup):

    For website testing:

    MerchBrowser.fla is located in http://www.mywebsite.com/remoting2/
    MerchProviderCFC.cfc is located in http://www.mywebsite.com/remoting2/
    MerchDetailProvider.cfm is located in http://www.mywebsite.com/remoting2/
    MerchRecordsetProvider.cfm is located in http://www.mywebsite.com/remoting2/
    Mydatabase.mdb is located in http://www.mywebsite.com/db/


    MerchBrowser.fla

    // Include support for Flash Remoting Components
    #include "NetServices.as"
    
    // uncomment this line when you want to use the NetConnect debugger
    // #include "NetDebug.as" 
    
    // --------------------------------------------------
    // Handlers for user interaction events
    // --------------------------------------------------
    
    // --------------------------------------------------
    // 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://www.mywebsite.com/flashservices/gateway")
      
      // connect to the gateway
      gateway_conn = NetServices.createGatewayConnection();
      
      // get a reference to a service
      // In this case, the "service" is the /ows/26 directory in web server root
      myService = gateway_conn.getService("mywebsite.remoting2.MerchProviderCFC", this);
    
      // Call the service function that fills the ListBox with a list 
      // of products (from ColdFusion) for the user to browse through
      myService.MerchDetailProvider();
    }
    
    // This function retrieves the detail information about the selected product.
    // It is executed when the last frame of the movie is reached
    // (when the detail view has finished hiding itself under the product list)
    
    
    // --------------------------------------------------
    // Handlers for data coming in from server
    // --------------------------------------------------
    
    // This executes when a merchandise detail record has been received
    function MerchDetailProvider_Result(result) {
      // The result variable is a recordset that contains just one row
      // The detailRecord variable will represent the row of data
      var detailRecord = result.getItemAt(0);
      
      // Display detail information in text boxes
    
      _root.DescriptionTextBox.text = detailRecord.MerchDescription;
    loadMovie("../images/" + detailRecord.ImageNameSmall, _root.ImageMovie);
    
      // If the ImageNameSmall column contains an image filename, display it
      
      // Now that the information about the merchandise has been placed,
      // make the display slide back into view, revealing the information
    
    }
    
    // Stop here, so animation doesn't occur until user selects a product
    stop();
    
    Code (markup):
    MerchProviderCFC.cfc

    <!--- 
     Filename: MerchProviderCFC.cfc
     Author: Nate Weiss (NMW)
     Purpose: Creates a ColdFusion Component that supplies data about products
    --->
    
    <cfcomponent hint="Provides data about merchandise records." output="false">
     
    
    <!--- merchDetailProvider() function --->
    <cffunction name="merchDetailProvider" returnType="query" access="remote"
     hint="Returns details about a particular item in the Merchandise table."
     output="false">
    
    
    	
    	<cfset var merchQuery = "">
    	
    	<!--- Query the database for merchandise records --->
    	<cfquery name="merchQuery" datasource=" Mydatabase.mdb" maxrows="1">
    	SELECT MerchID, MerchName, MerchDescription, ImageNameSmall, MerchPrice
    	FROM Merchandise 
    	WHERE MerchID = 12
    	</cfquery>
    	
    
    	
    	<!--- Return the query --->
    	<cfreturn merchQuery> 
     </cffunction>
    
    </cfcomponent>
    
    Code (markup):

    MerchDetailProvider.cfm

    Same as above example on localhost…
    
    Code (markup):

    MerchRecordsetProvider.cfm

    Same as above example on localhost…
    
    Code (markup):
     
    lespaul00, Jan 7, 2008 IP
  2. ldexterldesign

    ldexterldesign Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hmmm, i'm a little worried there are no responses of help here, as i've got to get stuck into this sort of thing this semester :confused:

    lespaul00 - what is it that you're exactly trying to achieve here?

    lewis
     
    ldexterldesign, Jan 12, 2008 IP
  3. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello Lewis, thanks for the response.

    All I want to do is have a .swf that displays an image based off of a query performed on one of my .cfm pages to my database. So, in essence, if the query passed the string "http://www.mywebsite.com/images/image01.jpg", then my flash file will display the image located in this location.

    I fooled around with AS1.0 and AS2.0 and read so many tutorials and examples, but it seems they all are outdated, or just are difficult to follow. I even downloaded the trial of Flash CS3 to see if AS3.0 would be easier. I am still not sure how to get it to work.

    My previous post showed an example (and my files) to how I got it to work on my localhost testing server. When I uploaded to my website, it didn't work. And yes, my website supports flash remoting, etc.

    Any help is appreciated. I am willing to try with AS2.0 or AS3.0... whichever you think is easier. But it needs to integrate with coldfusion and my access database.

    Thanks!!!
     
    lespaul00, Jan 12, 2008 IP
  4. Mirage

    Mirage Active Member

    Messages:
    204
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #4
    I'm afraid I have never worked in Cold Fusion before.

    But let me make a suggestion...

    Adobe has a set of forums where you will find a lot of knowledgeable people in flash. I'm afraid I do not know the URL since Macromedia became Adobe. However, if you go to the Adobe site and look for developer resources or some such, I'm sure you will find it.

    Good luck.
     
    Mirage, Jan 14, 2008 IP