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).

Figure 20.1. Text Fields for Display of Input and Output Histories

graphics/20fig01.jpg

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).

Figure 20.2. Input and Output History

graphics/20fig02.jpg



Flash and XML[c] A Developer[ap]s Guide
Flash and XML[c] A Developer[ap]s Guide
ISBN: 201729202
EAN: N/A
Year: 2005
Pages: 160

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net