title: AS3 / Flex 3 Staggered Remoting + Queue
body: <p>I am trying to make a class that staggers the net connections calls by a certain amount to not put too much pressure on my server, and so I don't have a dozen net connectors running around in my code. 
  I want a class that I can send a call command to, the class adds the call to the queue, and then about every one second it see if anything is in the queue, and if so calls it. This is what I have so far.</p>
  
  <pre><code>package net
  {
   import flash.events.TimerEvent;
   import flash.net.NetConnection;
   import flash.net.Responder;
   import flash.utils.Timer;
  
  
   public class Server 
   {
    private static var gateway:String = "http://localhost/gateway.php";
    private static var queue:Vector.&lt;ServerNode&gt;
    private static var nc:NetConnection;
    private static var instance:Server = null;
    private static var res:Responder;
    private var timer:Timer;
  
    public function Server(e:ServerEnforcer) {
     nc = new NetConnection();
     queue = new Vector.&lt;ServerNode&gt;();
     timer = new Timer(1000);
     timer.addEventListener(TimerEvent.TIMER, execCall);
     timer.start();
    }
  
    public static function getInstance():Server {
     if (instance == null) {
      instance = new Server(new ServerEnforcer);
     }
     return instance;
    }
  
    private function execCall(e:Event):void {
     if (queue.length &gt; 0) {
      var node:ServerNode = queue.pop();
      nc.call(node.method, node.res, node.args);
     }
    }
  
    public function call(method:String, success:Function, failure:Function, ...args):void {
     queue.unshift(new ServerNode(method, success, failure, args));
    }
  
    private function serverFailure(event:Object):void {
     trace("Server Failure : " + event.description);
    }
   }
  }
  import flash.net.Responder;
  
  class ServerEnforcer { } 
  
  class ServerNode {
   public var method:String;
   public var success:Function;
   public var failure:Function;
   public var args:Array;
   public var res:Responder
  
   public function ServerNode(_method:String, _success:Function, _failure:Function, _args:Array) {
    method = _method;
    success = _success;
    failure = _failure;
    res = new Responder(success, failure);
    args = _args;
   }
  }
  </code></pre>
  
  <p>Now when I call</p>
  
  <pre><code>Server.getInstance().call("Fetch.getData", parseAllData, onError)
  
  public function parseAllData(event:Object):void {
      trace("Victory!");
  }
  public function onError(event:Object):void {
      trace("Error :" + event);
  }
  </code></pre>
  
  <p>absolutely nothing happens.  Any idea why or a point in the right direction why this isn't working?</p>