You might try reading the Java class documents to see what is special about Vectors as opposed to Arrays in Actionscript.

The code is pretty simple. Have you tried to code and test it under ActionScript? It looks like you add objects to a list and take the first one off the list. It provides a function to find out if there are any objects in the queue.
What is wrong with this?

Ron

black59mga wrote:
I posted this a few day ago on Newbie. No response so posting here....

Does anyone know a simple way to serialize key events?

A Java prog. friend suggested using a "Mailbox" class to serialize the key 
input and provided a class (below) but I don't really understand java Vectors. Ideas?

thanks very much!




import java.util.*;

public class Mailbox {
  private int    numMessages = 0;
  private Vector mailbox = new Vector();

  public synchronized void insert(Object obj) {
    mailbox.addElement(obj);
    numMessages++;
    notify();
  }

  public synchronized Object remove() {
    while (numMessages == 0) {
      try {
        wait();
      } catch (Exception e) {
      }
    }

    Object obj = mailbox.firstElement();
    mailbox.removeElementAt(0);
    numMessages--;
    return obj;
  }

  public synchronized int numobj() {
    return numMessages;
  }

  public synchronized Vector flush() {
    Vector vector = null;
    if (numMessages > 0)
      vector = new Vector();
    while (numMessages > 0) {
      Object obj = mailbox.firstElement();
      vector.addElement(obj);
      mailbox.removeElementAt(0);
      numMessages--;
    }
    return vector;
  }
}
                        
---------------------------------
Yahoo! Mail goes everywhere you do.  Get it on your phone.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to