3 import flash.events.Event;
4 import flash.net.NetConnection;
5 import flash.net.Responder;
7 import nl.demonsters.debugger.MonsterDebugger;
10 * Wrapper class for the NetConnection/Responder instances
12 * This program is free software. It comes without any warranty, to
13 * the extent permitted by applicable law. You can redistribute it
14 * and/or modify it under the terms of the Do What The Fuck You Want
15 * To Public License, Version 2, as published by Sam Hocevar. See
16 * http://sam.zoy.org/wtfpl/COPYING for more details.
18 * @author Jordi Boggiano <j.boggiano@seld.be>
20 public class AMFConnector extends NetConnection {
21 private var responder:Responder;
22 public var data:Object;
23 public var error:Boolean = false;
25 public function AMFConnector(url:String) {
26 responder = new Responder(onSuccess, onError);
31 * executes a command on the remote server, passing all the given arguments along
33 public function exec(command:String, args:Array = null):void
35 if (args == null) args = [];
36 args.unshift(responder);
37 args.unshift(command);
38 (call as Function).apply(this, args);
44 protected function onSuccess(result:Object):void {
45 MonsterDebugger.trace(this, {'result':result});
47 dispatchEvent(new Event(Event.COMPLETE));
54 protected function onError(result:Object):void {
56 MonsterDebugger.trace(this, {'result':result});
58 dispatchEvent(new Event(Event.COMPLETE));