hi all,
i have a chat-like swf. here is the code:
FRAME 1:
time = "00:00:00";
createTextField("txt", 0, 0, 0, 190, 190);
txt.border = false;
txt.html = true;
FRAME 2:
chatData = new LoadVars();
chatData.load("http://localhost/mys/chat_flash.php?time=" + time);
chatData.onLoad =
function(){
for(i = 0; i < chatData.count; i++) {
nexttime = eval("chatData.time" + i);
nextmsg = eval("chatData.msg" + i);
nextsender = eval("chatData.sender" + i)
txt.htmlText += “<font face=‘Tahoma’ size=‘11’ color=’#336699’><b>” + nextsender + “</b> (” + nexttime + ")
";
txt.htmlText += “<font face=‘Tahoma’ size=‘11’ color=’#606060’>” + nextmsg + "</font><br><br>
";
if(nexttime > time) {
time = nexttime;
}
}
};
you see, it takes the biggest time value (initially it is 00:00:00) and sends it to php in order to get the messages inserted into db later than this “time” value. php code just selects and echoes from db if time value for a row is bigger than the received value via get method.
anyway, here is the last part:
FRAME 30: (OLD VERSION)
gotoAndPlay(2);
i thought this was a good algorithm for my purpose. as you see, it refreshes the data in every 30 sc by jumping from frame 30 to 2. (by the way, my swf is 1 fps, since i do not need any animation)
but that gave me just a headache! you guess what? whenever it comes to last frame, it resets the text field (erasing whatever i typed till that time) and jumps to frame 2! i couldn’t understand and solve that. and i revisited the code like that:
FRAME 30: (CURRENT)
if(this.inp.text.length == 0) {
gotoAndPlay(2);
}
else {
gotoAndPlay(25);
}
i wrote this stupid piece of code here in the 30th frame, because this doesn’t jump to the 2nd frame while is writing something. it just goes and comes between 25 and 30th frames, and waits for user to finish. (i thought so)
but that way did also behave like the first situation; it resets the input field!
i found a “partial” solution: i placed the input field on a new layer which is at the topmost position. that worked for me that time! now it doesn’t reset it; BUT, it is hard to write into input field! it is, like kind of freezing, and hard to find a chance to write.
i think you should see the actual files:
you will see all necessary info at [http://metalyric.net/chat_mx_php.html](http://metalyric.net/chat_mx_php.html)
please try to enter some text in swf file, you will see it's strangely hard. (and type speed is also slow???)
and if you can, please help.
thank you very much in advance.