mike chambers | about

Creating a Proxy for Flash using Flash Remoting and ServerSide ActionScript

This is a simple example that shows how to make a proxy using Flash Remoting and ServerSide ActionScript. The proxy will allow you to load XML and other data into Flash from domains other that the one the Flash movie was loaded from.

  1. Download and install the ColdFusion MX preview release.
  2. Download and install the Flash Remoting add-ons for Flash MX.

Create a file called Proxy.asr in the /wwwroot/com/macromedia/proxy directory.

Add the following code the Proxy.asr file"

function getURL(url)
	var stream = CF.http(url).get("Filecontent");
	return stream;

This takes a URL as a parameter and retrieves it using CF.http(). The remote data is retrieved by calling get(“Filecontent”) and stored in a variable named stream. The variable and its data is then returned to the Flash movie.

Next, open Flash, and add the following code to the first frame of the movie:

#include "NetServices.as"
#include "NetDebug.as"

Result = function(){};

Result.prototype.onResult = function(data)
	trace("Data : " + data);

Result.prototype.onStatus = function(error)
	trace("Error : " + error.description);

var remoteURL = "http://www.macromedia.com/desdev/resources/macromedia_resources.xml";

var gw = NetServices.createGatewayConnection("http://localhost:8500/flashservices/gateway");
var proxy = gw.getService("com.macromedia.proxy.Proxy", new Result());

Test the Flash movie in the authoring environment. You should see the Macromedia XML Resource feed printed out in the debug window. If an error occurs, a description should be printed in the Debug window (or you can check the NetConnection Debugger Window > NetConnection Debugger).

twitter github flickr behance