<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cata.printBlog(); &#187; AMF</title>
	<atom:link href="http://cata.onsysol.com/blog/tag/amf/feed/" rel="self" type="application/rss+xml" />
	<link>http://cata.onsysol.com/blog</link>
	<description>... it&#039;s about software!</description>
	<lastBuildDate>Sun, 30 May 2010 13:19:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash Remoting</title>
		<link>http://cata.onsysol.com/blog/2009/09/flash-remoting/</link>
		<comments>http://cata.onsysol.com/blog/2009/09/flash-remoting/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 15:12:27 +0000</pubDate>
		<dc:creator>Catalin Ciocov</dc:creator>
				<category><![CDATA[Action Script]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[flash remoting]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://cata.onsysol.com/blog/?p=4</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of Action Script recently and needed a good library for making flash remoting calls. If you Google a bit you&#8217;ll find a very good one (for AS3) here. I&#8217;ve started with this one, but because I needed some additional features I&#8217;ve decided to create my own version.
Specifically, I wanted the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of Action Script recently and needed a good library for making flash remoting calls. If you Google a bit you&#8217;ll find a very good one (for AS3) <a href="http://osflash.org/as3lrf">here</a>. I&#8217;ve started with this one, but because I needed some additional features I&#8217;ve decided to create my own version.</p>
<p>Specifically, I wanted the ability to specify a time limit for remoting calls and have multiple ways of getting the result back (since it&#8217;s an asynchronous call). Here are some examples.</p>
<p>Connect the the remote service:</p>
<pre>import com.onsysol.remoting.*;

var service:RemoteService = new RemoteService('http://myserver.com/gateway.php', 'MyService');
service.connect();</pre>
<p>Make a remote call to MyMethod() and receive the result via event listeners:</p>
<pre>service.addEventListener('onMyMethodResult', onMyMethodResult);
service.addEventListener('onMyMethodFault', onMyMethodFault);
service.MyMethod('param1', 'param2', 'etc...');

function onMyMethodResult(e:ResultEvent) {
    trace(e.result);
}

function onMyMethodFault(e:FaultEvent) {
    trace(e.fault);
}</pre>
<p>In case you don&#8217;t want to use an event listener for every remoting call you make you can simply listen for a &#8220;default&#8221; event triggered after every remoting call that doesn&#8217;t have a specific event listener registered for it. So, instead of the above, you could have:</p>
<pre>service.addEventListener(ResultEvent.RESULT, onResult);
service.addEventListener(FaultEvent.FAULT, onFault);
service.MyMethod();

function onResult(e:ResultEvent) {
    trace('Result event received from ' + e.prop['methodName']);
    trace(e.result);
}

function onFault(e:FaultEvent) {
    trace('Fault event received from ' + e.prop['methodName']);
    trace(e.fault);
}</pre>
<p>And finally, if you don&#8217;t want to use events at all to get the response, you could use callback/anonymous functions, like this:</p>
<pre>var prop:Object = {
    onResultCallback: function(result:Object, prop:Object) {
        trace('do something in your function...');
    },
    onFaultCallback: function(fault:Object, prop:Object) {
    }
};
service.call('MyMethod', prop, 'param1', 'param2', 'etc...');</pre>
<p>The default timeout is 2 seconds, but you can specify a new timeout value for all calls or on a per call basis:</p>
<pre>// General timeout value, used for all calls that don't have a specific timeout:
RemoteService.TIMEOUT = 5000;   // 5 seconds

// Make a remoting call with timeout set to 20 seconds:
service.call('MyMethod', {timeout: 20000}, 'param1', '...');</pre>
<p>You can handle timeouts by either registering specific event listeners (onMyMethodTimeout), using the generic event (onTimeout) or using callback/anonymous function (onTimeoutCallback) in a similar way to how a result or a fault is handled.</p>
<p>Download the library <a href="http://cata.onsysol.com/downloads/flashremoting.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cata.onsysol.com/blog/2009/09/flash-remoting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
