i've been working on my own chat... yadda yadda... I have this current code... it takes the info from the XML, and adds it to the text area that displays the chat logs... chatLog is a public static var...
So, first matter:
as of right now, the chat only updates if there's something new added... I want it to do that, but instead of completely changing everything (because images reload), I want it to just add it to the data... I know it would be added using +=, but i need some help figuring out how exactly to do it...
CODE
private function updateDone(event:ResultEvent):void
{
var i:int;
var tempString:String = "";
var tempString2:String;
var tempString3:String;
for(i=0; i<event.result.poster.length; i++)
{
if(event.result.bold[i] == 'yes'){
tempString2 = "<b>" + str_replace(":P","<img src=\"tongue.gif\">",event.result.content[i]) + "</b>";
}else{
tempString2 = str_replace(":P","<img src=\"tongue.gif\">",event.result.content[i]);
}
if(event.result.italics[i] == 'yes'){
tempString3 = "<i>" + tempString2 + "</i>";
}else{
tempString3 = tempString2;
}
tempString += "<font color=\"" + event.result.fontColor[i] + "\">" + event.result.poster[i] + ": " + tempString3 + "</font>" + "\n";
}
if(chatLog == tempString)
{
}
else
{
chatLog = tempString;
chatDisplay.htmlText = tempString;
chatDisplay.verticalScrollPosition = chatDisplay.maxVerticalScrollPosition;
}
}
Second matter:
as you've probaly seen, I use a custom function to replace the tempString with basically image parsing... so i turn

into an image... I want to be able to use arrays for it, but i'm not sure how... i know in PHP you can replace the array keys with the array values, but i'm not sure about actionscript...
so i'd make an array that contains things like ":P" i want to replace as a key, and things like "<img src=\"tongue.gif\">" as a value...
anyway, here's the current function:
CODE
private function str_replace(replace_with:String, replace:String, original:String):String
{
var array:Array = original.split(replace_with);
return array.join(replace);
}
and a third thing:
when I replace the text with an image, i end up with this....

i'm not sure if it's a problem with my code, or just really bad placing =/
This post has been edited by JBrace1990: 17 Jul, 2008 - 01:50 PM