Mar
27
2003

ff2003: integrating flash and cold fusion

current session: “Integrating Flash and Cold Fusion,” presented by Christian Cantrell, of Macromedia.

Developing applications in Flash often requires integration with another technology in order to achieve the desired results. This session will explore the reasons why full-featured Flash applications need a backend and why that back-end should be ColdFusion. You will learn how to integrate Flash MX and ColdFusion MX, including sending data from Flash to ColdFusion and returning data from ColdFusion to Flash. Cantrell will discuss integrating Flash MX and ColdFusion using XML, including exchanging data between Flash and ColdFusion using XML and encapsulating your XML on the client and on the server. This presentation will also explain integrating Flash MX and ColdFusion using Flash Remoting, including calling remote ColdFusion components from Flash, encapsulation on the server using ColdFusion components and encapsulating Flash Remoting on the client.

Note: This entry is being posted after the fact. I took notes during the session, but didn’t have a chance to write it up in narrative format until Monday, March 31.

Cantrell said he would post his presentation to his website. He hasn’t posted it yet, but on his weblog, he posted an answer to an attendee’s question about using cflogin with Flash Remoting.

So … On with the selling of Flash Remoting and Cold Fusion MX:

Why not use XML or loadVariables? - Flash Remoting allows you to invoke remote functions almost as easily as if they were local ActionScript functions, and the action is more seamless. FR also allows you to pass objects and complex data structures directly between the Flash client and the server, rather than have to pass and parse string data.

Getting started with Flash Remoting - To run Flash Remoting, you need Flash MX (Remoting will not run on Flash 5 or below), Remoting components for Flash MX and a server with Remoting installed (this comes by default if your server is running Cold Fusion MX or JRun 4). Remoting also works with other database backends, but you have to pay for the server extensions. Cantrell added that you can use Remoting with a PHP backend. It’s not supported by Macromedia, but someone made a hack to get it to work.

Creating packages for Flash Remoting services - All Flash Remoting services are set up as packages. When you’re setting up a Flash Remoting application, use consistent naming conventions and directory structures to help organize and mantain services. It is a common practice to use your domain name as part of your package name to eliminate the possibility of naming conflicts, should you share CFCs with other people/projects. CFCs cannot be referenced relatively (“../services/etc”); they must be referenced absolutely (“com.macromedia.services.etc”).

Introduction to Cold Fusion components - Cold Fusion components are a series of one or more functions contained in a .cfc file, which can then be invoked via Flash Remoting or Cold Fusion. CFCs are written entirely in CFML, with a few additional component-specific tags. They are modeled after Java objects and share many of the same concepts, such as a structure that allows a single component to contain several functions and provide multiple services. You can also set up access parameters to that anyone, or only certain functions/clients, can invoke them.

Performing a database query using CFCs - The entire query object returned by CFQUERY can be turned into a remote Flash object. You can set a page size which determines the number of rows the server will return to the client until the client asks for more. When building/testing your application in Flash, you can use netdebug.as, which will log and display all server/client interaction in the netconnection debugger window.

Metadata and remote browsing - This is especially helpful in cases where the Flash engineer and the back-end programmer are working separately. Within the Flash authoring environment, you can use Remote Service Browsing to browse through available remote services (implemented as CFCs). Remote Service Browsing looks through the CFCs for documentation/description data embedded in the various functions via the “hint” attribute. Additionally, if you try to directly call up a CFC in a browser (“http://mydomain.com/services/myservice.cfc”), the CFC will return the same description information. Both of these are good ways for the Flash engineer to stay apprised of what the back-end programmer is working on and what the relevant variables/function names are, without having to open the actual CFC file.

Post a comment

As a spam-control measure, your comment may require my approval before it will appear on the entry. Thanks for waiting. To avoid the moderation delay, consider filling in your e-mail address. It won't appear on the site, but I use it to whitelist frequent commenters so their comments appear automatically.


The following HTML tags are permitted (if you want to use them):
p, br, a href, b, strong, u, i, em, ol, ul, li, cite, blockquote