This is one of those subjects that keep coming up again and again: How to clear the chat history.

Most commonly known chat systems do not show you the conversations that have gone on before the user logs in. Developers therefore often like to emulate this behaviour in their FlashCom applications.

There are several ways of clearing a chat. The chat history is held in a server side persistent shared object (SSPSO) by default. If you clear the contents of this object then all clients will reflect this change immediately through their onSync event.

The following tutorial presumes that you are using Macromedia's Communication Components.

Option 1: Clearing the history on the client side only - the lazy way
Lazy way meaning you are not actually clearing the shared object which holds the history on the server but you are simply resetting the chat text field inside one client's movie to an empty string, effectively clearing it.

All you need to do is for example to add the following code to frame one of your movie (in this case your chat component instance must be called chat_mc):
chat_mc.history_txt = "";

To make it more robust you can also put this line of code into an onLoad() event of the chat_mc movie or provide a function that can be called by the user, for example when clicking a button.
Your function on frame 1 of the main timeline could be:
function clearHistory() {

and all you then need is a pushbutton, it will call the function clearHistory() when clicked by a user:

Hopefully this will point you in the right direction for integrating it with your own application. Next week we will look at how to clear the server side shared object on the server and broadcasting this change to all connected users, clearing the chat on each client.

Make sure to also check the second part of this tutorial