You are here: Recent News » Projects » ssr

 
Table of Contents

ssr

Tags : ,

Summary

SSR is a Super Simple Remoting package for Actionscript 3 and can be used with Flex 2 as well. Services are created, and each call can supply it’s own onResult and onFault handlers. Timeouts and MaxAttempts for each service call can also be specified. Using callbacks for each service call reduces the amount of code needed to use remoting in Flash / Flex.

Example

package
{

	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import org.rubyamf.remoting.ssr.RemotingService;
	import org.rubyamf.remoting.ssr.ResultEvent;
	import org.rubyamf.remoting.ssr.FaultEvent;

	class MyServiceTest extends Sprite
	{
		
		private var service:RemotingService;
		
		private function MyServiceTest()
		{
			service = new RemotingService('http://localhost:8024/gateway.rb','test.Test', [0/3]);
			service.addEventListener(FaultEvent.CONNECTION_ERROR, onConnectionError);
			myButton.addEventListener(MouseEvent.CLICK, testService);
		}
		
		function onConnectionError(fe:FaultEvent):void
		{
			trace("Connection Error: " + fe.fault);
		}
		
		function onResult(re:ResultEvent):void
		{
			trace(re.result);
		}
		
		function onFault(fe:FaultEvent):void
		{
			trace(fe.fault.faultString);
		}
		
		function testService(e:Event):void
		{
			//perform the service call
			service.helloWorld(['Hello World!'], onResult, onFault, {timeout:3000, maxAttempts:2});
		}
	}
}

Download

Discussion

projects/ssr.txt · Last modified: 2007/05/15 22:52 by aaronsmith