You might want to read "Head First Design Patterns" for some good ideas
about how to write good code.
Lots of practical ideas about many of te situations that you need to
resolve.
Ron
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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