Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3681236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:40:04+00:00 2026-05-19T03:40:04+00:00

I am trying to make a class that staggers the net connections calls by

  • 0

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.

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.<ServerNode>
  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.<ServerNode>();
   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 > 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;
 }
}

Now when I call

Server.getInstance().call("Fetch.getData", parseAllData, onError)

public function parseAllData(event:Object):void {
    trace("Victory!");
}
public function onError(event:Object):void {
    trace("Error :" + event);
}

absolutely nothing happens. Any idea why or a point in the right direction why this isn’t working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:40:05+00:00Added an answer on May 19, 2026 at 3:40 am

    You created an instance of the NetConnection, but haven’t actually initiated a connection with the server.

    In other words,

    nc.connect(gateway);
    

    is missing.

    See NetConnection documentation for more information on that class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/JamesKyle/re73T/ Trying to make a class switcher that will do the following: On Load
I am trying to make a class that will represent two different behaivours at
I am trying to extend the mysqli class to make a helper class that
A am trying to make a program that takes a signal from one class
I'm trying to build a small class-like container that will make it a little
I'm trying to make a class where I put a key and value into
I'm trying to make a class that has a simple integer with in it.
I'm trying to make a class that extends qwidget, that pops up a new
I'm currently trying to make a class that can register strings as identifiers and
I'm trying to make a generic class that takes 3 types, either a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.