The most basic communication method in a virtual world is public chat channel. A public message is populated to all players within the same room. The public message mechanism is like people talking loudly in a room. All people can listen and join the conversation. However, when they leave the room, they cannot listen to the conversation anymore. This is exactly how public message behaves in a virtual world.
We are going to make a chat dialog for public chat. The chat is composited by two parties — the sender and the receiver. The sender is a client which speaks the message out loud. The receivers are the clients which are in the same room and listening to the public chat message event. The chat dialog acts as both; the conversation log in the upper half acts as receiver and displays the messages. The lower half allows users to send out messages. This chat dialog is exported as ChatBox
ActionScript class and we will implement the behavior with the following code...