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:
- // remoting
- import mx.remoting.Service;
- import mx.remoting.PendingCall;
- import mx.rpc.RelayResponder;
- import mx.rpc.ResultEvent;
- import mx.rpc.FaultEvent;
- var peopleService:Service = new Service("http://localhost:3000/rubyamf/gateway", null, "PeopleController", null, null);
- var peopleCall:PendingCall = peopleService.index();
- peopleCall.responder = new RelayResponder(this, "onList", "onFault");
- function onList(re: ResultEvent): Void
- {
- var people:Object = re.result;
- for (var i = 0; i <people.length; i++) {
- for (var j in people[i])
- {
- trace(j + ": " + people[i][j]);
- }
- }
- }
- function onFault(fault:FaultEvent): Void
- {
- trace("PeopleRest::onFault: " + fault);
- }