mike chambers | about

DevCon : Video Blog : Morning Update

Video files no longer available.

Files from video:

before.as

#include "NetServices.as"

var result = new Object();

result.onResult = function(data)
{
	trace(data);
}

result.onStatus = function(info)
{
	trace(info.description);
}

var server = NetServices.createGatewayURL("http://127.0.0.1/flashservices/gateway");
var service = server.getService("com.domain.test", result);

service.createName("homer", "simpson");

after.as

#include "NetServices.as"
#include "Foo.as"

var f = new Foo();

f.setFirstName("Mike");
f.setLastName("Chambers");

f.onName = function(name)
{
	trace(name);
}

f.createName();

Foo.as

Foo = function()
{
	if(_global.NetServices == undefined)
	{
		trace("NetServices.as is required and must be included before Foo.as");
	}
}

Foo.prototype.gatewayURL = "/flashservices/gateway";
Foo.prototype.firstName = null;
Foo.prototype.lastName = null;

Foo.prototype.setGatewayURL = function(url)
{
	this.gatewayURL = url;
}

Foo.prototype.setFirstName = function(firstName)
{
	this.firstName = firstname;
}

Foo.prototype.setLastName = function(firstName)
{
	this.lastName = lastName;
}

Foo.prototype.createName = function()
{
	var server = NetServices.createGatewayURL(this.gatewayURL);
	var service = server.getService("com.domain.test", this);

	service.createName(this.firstName, this.lastName);
}

Foo.prototype.createName_Result = function(data)
{
	this.onName(data);
}

Foo.prototype.createName_Status = function(info)
{
	if((typeof(this.onError) != "function"))
	{
		trace("Error : " + info.description);
	}

	this.onError(info);
}
twitter github flickr behance