mike chambers | about

Setting up a namespace on the Client object on the Flash Communication Server

I have been writing some Flash Communication Server code (on the server side), and had a need to connect methods and properties to the Client object. Normally, I would use _resolve so i would not have to attach methods directly to the Client object, but doing that would mean that my code could not work with the Flash Communication Server components, which also define _resolve.

The solution, was to create a namespace on the Client object and store my data there.

Client.prototype.MyNameSpace = new Object();

Client.prototype.MyNameSpace.foo = function()
{
	trace("foo");
}

When calling the method from Flash, just remember to insert the namespace:

nc.call("MyNameSpace.foo", null);

While this is not the best solution (_resolve is), is does help ensure that you will not have namespace collisions with other server side code that may attach properties or functions to the Client object.

twitter github flickr behance