Hello everyone!
It's been a while since I posted on this site. I'm sorry about that, I've just been a little busy on a new project I'm working on. Anyway, as you can tell from the post title, this tutorial is on how to create a chat log. The chat log we create in this tutorial will have an auto-scrolling feature. Anyway, let's get started!
First things first, I'm using an avatarChat example file from SmartFoxserver. So, let's go ahead and open that file up.
After the file is opened, go to the 'chat' frame and put a dynamic text box on the stage and give it an instance name of chatLog and make sure you tick the box shown below so that it has HTML abilities.
After you do that, you need to open up the 'chat' frame's coding. After the coding is up, scroll down until you find a SmartFoxServer handler called "smartfox.onPublicMessage." Add this coding inside that handler:
//New Chat Log Coding:
//--Basic Add Message Coding:
chatLog.htmlText += user.getName() + ": " + msg + newline; //Add text to textbox
//--Basic Auto-Scroll Coding:
var logVar = 1; //Creates a variable, you might want to increase this
chatLog.scroll = logVar; //Scrolls textbox to variable amount
logVar++; //Increases variable value
Pretty basic coding, as you can see. Here is an image of where I added that coding in my Flash file:
(Coding in the image isn't correct, use the coding as shown above!)
Well, after you do that, test the movie and it should be working fine.
If you encounter any problems with this be sure to leave a comment and I'll get back to you as soon as I can.
Source File: Download