-
Split var
Hello,
i am try to make a KoolMoves chat.
Now it's almost finish, but only one problem.
I have 2 Dynamic text fields, one = txt1.text and two = txt2.text
I wanna split one line (from the perl script), the text a user is get from a other user, and who's online (the names).
So the perl script (see http://www.screensave.nl/get.pl)
when you call it, it will show a line like this;
i=text1;text2;text3&p=user1;user2;user3 etc..
But how can i split the line, so that it first split the [ i ] text and value and after that the [ p ] the usernames in a other dynamic text field in just one update..
I use the code below for the text update, and try a lot to change to make it posable to update text and users but till now no success, so i realy hope some one can help me.
Thank you
Hans
update= function (){
_root.loadVariables("http://www.screensave.nl/get.pl", "POST");
records = i.split(';');
for (var b = 0; b < records.length; b++){
txt1.text=txt1.text+records[b]+'\n';
}
i = "";
_root.txt1.text.scroll += 18;_level0.dwn = 1;
}
setInterval( update, 5000, );
update();
-
Code:
update= function (){
txt1.text="";
var result_lv= new LoadVars();
result_lv.onLoad = function(success) {
if (success) {
myusers = result_lv.p.split(';');
for (var b=0; b < myusers.length; b++){
txt1.text+= myusers[b]+'\n';
}
} else {
//do something else
}};
var send_lv = new LoadVars();
send_lv.sendAndLoad("http://flashnow.servebbs.com/examples/split.txt", result_lv, "POST");
}
setInterval( update, 5000, );
update();
I'm using a flat text file to emulate your cgi return but you get the idea :)
http://flashnow.servebbs.com/examples/hansverst2.html
-
Thank you Chris
Hi Chris tnx for reply,
And i get the idea, and works just fine now!
i think it's working better now with 'sendAndLoad'
Thank you for your help.
Hans
-
Glad to help :thumbsup: :thumbsup: