Client with History
The goal here is to extend the one-line input area and the one-line display of our Flash client so that we can view the past messages we sent and the ones that have come in. These displays will no longer be the same string. We will see messages from other clients, not just our own messages echoed back (Figure 20.1).

ActionScript
function transmit() {
textOut+=" ";
textOut= "<msg>"+textOut.slice( 0, 36)+"</msg>";
socko.send( new XML(textOut) );
textOut3= textOut2;
textOut2= textOut1;
textOut1= textOut0;
textOut0= textOut;
textOut="";
}
function received(msg) {
textIn3= textIn2;
textIn2= textIn1;
textIn1= textIn0;
textIn0= textIn;
textIn = msg.toString();
}
We created four lines each of input and output history. Rather than any fancy, smooth, onscreen scrolling, we just scroll the data through the variables (Figure 20.2).

|