Slet af tekst i multiline tekstbox eller reload af xml problem.
Hejsa.Jeg har et problem med min flash shoutbox.
poroblemet er, hver 5 sek skal den genindlæse xml'en så man kan se de nye beskeder.
har denne kode indtil nu.
-------------------------------------
function loadXML(loaded){
if(loaded){
var myXML = xmlData.firstChild.childNodes;
_global.nameA=[];
_global.messageA=[];
for(i=0;i < myXML.length;i++){
_global.nameA[i] = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_global.messageA[i] = this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nodeValue;
shouts.htmlText += "<b>" + nameA[i] + "</b>";
shouts.htmlText += messageA[i] + "<br>";
}
}
}
shouts.htmlText = "";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
var uniquefirst=new Date().getTime()
xmlData.load("shout.php?unique="+uniquefirst);
update = false;
_root.onEnterFrame = function(){
if(update){
//Al din xml-opdateringskode
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
var unique=new Date().getTime()
xmlData.load("shout.php?unique="+unique);
update = false;
}
}
setInterval(reload, 5000) // reload every 5 seconds
function reload()
{
if(update == false)
{
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
var unique=new Date().getTime()
xmlData.load("shout.php?unique="+unique);
}
}
send_btn.onPress = function(){
if (name_txt.text eq "" or message_txt.text eq ""){
status_txt.text = "error";
}else{
var container:LoadVars = new LoadVars();
container.name = name_txt.text;
container.message = message_txt.text;
container.submit = true;
container.send("post.php","_self", "POST");
//_root.status_txt.text = "shout sent";
}
}
reset_btn.onPress = reset_btn.onRelease = function(){
_root.name_txt.text = "";
_root.message_txt.text = "";
}
onEnterFrame = function(){
if (_root.up) {
_root.shouts.scroll += 1;
} else if (_root.down) {
_root.shouts.scroll -= 1;
}
}
---------------------------------------------
tror mit problem er i
setInterval(reload, 5000) // reload every 5 seconds
function reload()
{
if(update == false)
{
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
var unique=new Date().getTime()
xmlData.load("shout.php?unique="+unique);
}
}
fordi det eneste den gør, er at loade den samme tekst ind igen og igen.
ved ikke om jeg skal slette gammel text i textfelt -> genindlæs ny xml
eller kan bare nøjes med at genindlæse min xml...
nogen ide'er om hvordan jeg kan fixe det ?
Takker.
