<?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>Flash Remoting for Ruby on Rails &#187; AS3</title>
	<atom:link href="http://blog.rubyamf.org/category/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rubyamf.org</link>
	<description>Ruby AMF - Flash Remoting for Ruby on Rails</description>
	<lastBuildDate>Tue, 25 Aug 2009 12:23:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Guttershark Actionscript 3 Library</title>
		<link>http://blog.rubyamf.org/2008/05/10/guttershark-actionscript-3-library/</link>
		<comments>http://blog.rubyamf.org/2008/05/10/guttershark-actionscript-3-library/#comments</comments>
		<pubDate>Sun, 11 May 2008 02:35:18 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=109</guid>
		<description><![CDATA[I&#8217;ve been working quite a bit recently to get this Flash Actionscript 3 library ready. Check out the first beta.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working quite a bit recently to get this Flash Actionscript 3 library ready. Check out the <a href="http://www.guttershark.net">first beta</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2008/05/10/guttershark-actionscript-3-library/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SSR 2 Breakdown</title>
		<link>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/</link>
		<comments>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 04:36:47 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[AMF]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[SSR]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=103</guid>
		<description><![CDATA[John Farrar had asked about SSR 2 &#8211; more information on SSR and what benefits / things you get with it. I thought I&#8217;d be a little more specific and outline what it is and what you get. Bare with me if I start out by pointing out the obvious.
So, I guess here&#8217;s the obvious. [...]]]></description>
			<content:encoded><![CDATA[<p>John Farrar had asked about SSR 2 &#8211; more information on SSR and what benefits / things you get with it. I thought I&#8217;d be a little more specific and outline what it is and what you get. Bare with me if I start out by pointing out the obvious.</p>
<p>So, I guess here&#8217;s the obvious. SSR is a small AS3 remoting library. Stands for &#8220;Super Simple Remoting&#8221; because it&#8217;s simple. My goal when writing it was to make one library that works in Flash and Flex and handle logic that should be in every application. Personally I like using this in both Flash and Flex because I don&#8217;t forget how to use it. I always forget how to use RemoteObject so this makes a standard library for either.</p>
<p>So here&#8217;s an example of a bare minimum setup of SSR to make a remoting call.</p>
<pre>
import com.niarbtfel.remoting.RemotingConnection;
import com.niarbtfel.remoting.RemotingService;
import com.niarbtfel.remoting.events.FaultEvent;
import com.niarbtfel.remoting.events.ResultEvent;

var rc:RemotingConnection = new RemotingConnection("http://localhost/myGateway",3);
//gateway
//3 is the amf format

var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
//rc is the remoting connection to use for this service
//"MyService" is the service target on the server.
//4000 is the amount of time a call waits before retrying the call.
//3 is the amount of retries to attempt per call.
//true turns on call limiting, which means that the same exact call can't be made while one is waiting for a response or timeout.

//callbacks for calls, keep reading.
function onr(re:ResultEvent):void{}
function onf(fe:FaultEvent):void{}

//callbacks for calls, keep reading.
function onrArgs(re:ResultEvent,args:Array):void{}
function onfArgs(fe:FaultEvent,args:Array):void{}

rs.myMethod([],onr,onf,false); //make a call
//[] = call arguments
//onr is the result callback
//onf is the fault callback
//false - don't return the original arguments sent in the request to the callback functions

var mym:String = "myMethod";
rs.apply(mym,[],onrArgs,onfArgs,true); //make a call
//[] = call arguments
//onr is the result callback
//onf is fault callback
//true - return the original arguments sent in the request to the callback functions
</pre>
<p>This is the simplest form of setting up flash remoting with SSR without any event listeners on the RemotingConnection or RemotingService. Events for RemotingConnection and RemotingService are documented in the class files. You get events for things like disconnects, retries, timeouts, etc.</p>
<p>Each RemotingService can have a timeout specified for each call going to that service, as well as a maximum attempts allowed per call. If one call is made, but doesn&#8217;t receive a response within the timeout specified, it&#8217;s tried again. This happens over and over until the maximum attempts is reached, and a timeout event is dispatched.</p>
<p>RemotingService has an option to turn on call limiting. Which makes the remoting service smart about what to call and what not to call. If you made a call to &#8220;MyService.myMethod&#8221; with parameters ["something","something else"], it would not let you make that same call until the first one has completed, or has timed out. You&#8217;d still be able to make calls to any other service method.</p>
<p>Another new feature is caching. Say you make calls to some service numerous times, but the data is always the same. Instead of doing that you can enable the service to use caching. Here&#8217;s a snippet from above with caching in place:</p>
<pre>
var rs:RemotingService = new RemotingService(rc,"MyService",4000,1,true);
rs.remotingCache = new RemotingCache(-1);
//-1 specifies that the cache should never expire. (supply a time in milliseconds for an expiration if needed)
</pre>
<p>Now every call made through this remoting service will be cached. If the exact same call is made, the results are pulled from cache instead.</p>
<p>SSR also has paging built in with a RemotingPager. Here&#8217;s a snippet on how that works:</p>
<pre>
import com.niarbtfel.remoting.RemotingConnection;
import com.niarbtfel.remoting.RemotingService;
import com.niarbtfel.remoting.events.FaultEvent;
import com.niarbtfel.remoting.events.ResultEvent;
import com.niarbtfel.remoting.paging.RemotingPager;
import com.niarbtfel.remoting.paging.PageResponder;

var rc:RemotingConnection = new RemotingConnection("http://localhost/myGateway",3);
var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
var rp:RemotingPager;
var pr:PageResponder // just to include in compilation

var totalRecordsOnServer:int = 400; //should come from server instead.

//callbacks for calls, keep reading.
function onrArgs(re:ResultEvent,args:Array):void
{
  rp = new RemotingPager(rs,"myMethod",PageResponder,["someParameter"],re.result as Array,totalRecordsOnServer,50,2,1);
  myButton.addEventListener(MouseEvent.CLICK, onbc);
}
function onfArgs(fe:FaultEvent,args:Array):void{}

function onbc(me:MouseEvent):void
{
   if(rp.hasNext())
   {
     trace(rp.next());
   }
   else
   {
     trace("no more pages");
   }
}

rs.myMethod(["someParameter",0,50],onrArgs,onfArgs,true); //make a call to get the initial data.
//0 is the offset
//50 is the pagesize
</pre>
<p>In this example, a remoting pager is created in the result callback of the first call. A remoting pager needs at least the first page in order to be created. The RemotingPager takes care of &#8220;pre-fetching&#8221; pages with buffer options. In the above example, where the RemotingPager is created, 50 is the pagesize to grab, 2 is the amount of pages to buffer / pre-fetch. And 1 is the amount of pages that are left in the buffer before triggering another buffer fill / pre-fetch. This is the simplest form of paging, but the RemotingPager has methods for getting certain pages, getting them all, seeking, etc.</p>
<p><strong>UPDATE: I forgot to mention RemotingService.MaxTimeoutsBeforeHault.</strong></p>
<p>With RemotingService.MaxTimeoutsBeforeHault, you can control how many timeouts are allowed from any call, before all remoting calls are stopped. Here&#8217;s a snippet:</p>
<pre>
RemotingService.MaxTimeoutsBeforeHault = 3;
var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
rs.addEventListener(CallEvent.SERVICES_HALTED, onch);
function onch(ce:CallEvent):void{}
rs.myMethod([],onR,onF,true);
</pre>
<p>When you set this property, any call that causes a timeout, is kept track of, and if 3 timeouts happen from any call, no other remoting calls will be made. Each attempt after the services are halted, dispatches the CallEvent.SERVICES_HALTED event.</p>
<p>In conclusion &#8211; SSR gives you logic out of the box that should be available anytime we are using Flash Remoting. And gives you numerous other features. SSR 2 is documented very well in the source files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>TweenLite isTweening Method.</title>
		<link>http://blog.rubyamf.org/2007/12/10/tweenlite-istweening-method/</link>
		<comments>http://blog.rubyamf.org/2007/12/10/tweenlite-istweening-method/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 20:17:11 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=95</guid>
		<description><![CDATA[I&#8217;m on a project right now that&#8217;s using TweenLite But it&#8217;s missing the isTweening method. Here it is:
First update the constructor:
Line 180/181 should look like this:

_all[$target][this] = this;
_all[$target]['instance'] = this;

In the executeAll() function, there is an innter for loop, change it to this:

for (twp in a[p]) {
 if(twp == 'instance')
  continue;
 tw = a[p][twp];
 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m on a project right now that&#8217;s using TweenLite But it&#8217;s missing the isTweening method. Here it is:</p>
<p>First update the constructor:<br />
Line 180/181 should look like this:</p>
<pre>
_all[$target][this] = this;
_all[$target]['instance'] = this;
</pre>
<p>In the executeAll() function, there is an innter for loop, change it to this:</p>
<pre>
for (twp in a[p]) {
 if(twp == 'instance')
  continue;
 tw = a[p][twp];
 if (tw != null &#038;&#038; tw.active) {
 tw.render(t);
 }
}
</pre>
<p>Then add this somewhere at the bottom:</p>
<pre>
public static function isTweening(target:*):Boolean
{
  if(_all[target] == null)
    return false;
  var t:* = _all[target] as Dictionary;
  var instance:TweenLite = t['instance'] as TweenLite;
  return instance.active;
}
</pre>
<p>Hope that helps someone out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/12/10/tweenlite-istweening-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
