What I would do is have the Queue class be a listener of the connection
class, and not pass that data at all. When a connection is detected, a
notice is fired off to the listeners (the Queue class). You can send
the connection info in the message to the Queue, then in the Queue class
can the send the data.
Russ.
Andrew wrote:
Hi
I'm new to OOP programming in AS2.
I'm writing two classes right now. One which creates/manipulates an
array of XMLNodes and one which watches for an internet connection.
When it finds a connection, it starts to send the XMLNodes from the
queue back to a server one by one.
So far I've written the Queue class.
class com.Queue {
private var _milestoneXMLNode:XMLNode;
private var _aQueue:Array;
//Constructor
public function Queue() {
_aQueue = new Array();
}
//Methods
public function addMilestoneToQueue(milestoneXMLNode:XMLNode):Void {
_aQueue.push(milestoneXMLNode);
}
private function getQueue():Array {
return _aQueue;
}
private function getFirstMessageInQueue():XMLNode {
return _aQueue[0];
}
private function deleteFirstMessageFromQueue():Void {
_aQueue.splice(0,1)
}
}
Now the real question I have is how to get the first element from the
Queue, i.e. _aQueue[0] from the Queue class into the Connection class
so that it can be sent back to the server?
class com.Connection {
private var _isConnection:Boolean;
//Constructor
public function Connection() {
//No connection by default
_isConnection = false;
}
//Methods
private function detectConnection():Void {
//
}
}
How do I do this? Or does this break encapsulation? I'm a bit stuck,
would appreciate any advice.
Cheers
Andrew
_______________________________________________
[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