Thursday 2007/10/25
2:41 PM

Categories: Flash/Actionscript, Ruby/Rails, RubyAMF, Web Dev, Work

RubyAMF and AS2 (follow-up to AS3 + SSR, RubyAMF, and RESTful Rails)

A quick follow-up post to my tutorial on Flash and RubyAMF — RubyAMF can of course be used with AS2. Here's a short AS block showing a call to the index method of the PeopleController:


Actionscript:
  1. // remoting
  2. import mx.remoting.Service;
  3. import mx.remoting.PendingCall;
  4. import mx.rpc.RelayResponder;
  5. import mx.rpc.ResultEvent;
  6. import mx.rpc.FaultEvent;
  7.  
  8. var peopleService:Service = new Service("http://localhost:3000/rubyamf/gateway", null, "PeopleController", null, null);
  9. var peopleCall:PendingCall = peopleService.index();
  10. peopleCall.responder = new RelayResponder(this, "onList", "onFault");
  11.  
  12.  
  13. function onList(re: ResultEvent): Void
  14. {
  15.     var people:Object = re.result;
  16.     for (var i = 0; i <people.length; i++) {
  17.         for (var j in people[i])
  18.         {
  19.             trace(j + ": " + people[i][j]);
  20.         }
  21.     }   
  22. }
  23.  
  24. function onFault(fault:FaultEvent): Void
  25. {
  26.     trace("PeopleRest::onFault: " + fault);
  27. }


Responses


malice

Tuesday 2007/10/30 2:10 PM

yeah, i think i saw that in a movie once.


ds

Tuesday 2007/10/30 2:32 PM

Are you not entertained?


Leave a Response