Previous | Next | Frames | No Frames |
Summary: Field | Property | Contructor | Method | Detail: Field | Property | Contructor | Method |
MovieClip | +--it.gotoandplay.smartfoxbits.bits.ChatBox
To use the ChatBox for private chatting, set the privateChatMode property to true
and set the privateChatUserId property to the user ID of the user you want to establish private communication with.
NOTE: public user interaction is not enabled if a "Limbo" room is joined.
import it.gotoandplay.smartfoxbits.bits.ChatBox var chatBox_mc:ChatBox = ChatBox(attachMovie("ChatBox", "chatBox_mc", 2)) chatBox_mc.labelText = "Enter your message here"
NOTE 1: importing the it.gotoandplay.smartfoxbits.bits.ChatBox class and casting the ChatBox's movieclip to it is useful if you intend to use a development tool having code-completion features. Otherwise this is enough:
var chatBox_mc = attachMovie("ChatBox", "chatBox_mc", 2)NOTE 2: in the following examples chatBox_mc represents the ChatBox instance name.
Property Summary | |
public | adminMessageHeader: String (read, write) |
The html text displayed before an Administrator message in the main chat area. | |
public | chatTextArea: TextArea (read-only) |
A reference to the chat TextArea component. | |
public | clearButton: Button (read-only) |
A reference to the "clear" Button component. | |
public | colorPicker: ColorPicker (read-only) |
A reference to the ColorPicker component. | |
public | groupMessages: Boolean (read, write) |
Group messages per sender. | |
public | height: Number (read, write) |
The height of the ChatBox component on the stage, in pixels. | |
public | initialMessage: String (read, write) |
The initial message to be displayed inside the message input field. | |
public | labelText: String (read, write) |
The text of the label located above the message input field. | |
public | messageHeader: String (read, write) |
The html text displayed before a message in the main chat area. | |
public | messageLabel: Label (read-only) |
A reference to the message input Label component. | |
public | messageQueue: Array (read-only) |
The queue of sent and received messages. | |
public | messageTextInput: TextInput (read-only) |
A reference to the message TextInput component. | |
public | moderatorMessageHeader: String (read, write) |
The html text displayed before a Moderator message in the main chat area. | |
public | privateChatMode: Boolean (read, write) |
Enable/disable the "private chat" mode. | |
public | privateChatUserId: Number (read-only) |
The SmartFoxServer ID of the user the ChatBox is listeng to in "private chat" mode. | |
public | restrict: String (read, write) |
The set of characters that a user may or may not enter into the message input field. | |
public | roomJoinAlert: String (read, write) |
The html text displayed in the main chat area when the user joins the chat room. | |
public | sendButton: Button (read-only) |
A reference to the "send" Button component. | |
public | sendButtonText: String (read, write) |
The label of the "send" button. | |
public | showClearButton: Boolean (read, write) |
Show/hide the "clear" button. | |
public | showColorPicker: Boolean (read, write) |
Show/hide the color picker tool. | |
public | showFocusRectangle: Boolean (read, write) |
Show/hide the focus rectangle around the input field, the color picker and the send button. | |
public | spacing: Number (read, write) |
The number of pixels dividing the ChatBox sub-components (message input field, color picker, send button, chat text area). | |
public | systemAlertsColor: Number (read, write) |
The default color of system messages in the main chat area. | |
public | userEnterRoomAlert: String (read, write) |
The html text displayed in the main chat area whenever a user enters the chat room. | |
public | userLeaveRoomAlert: String (read, write) |
The html text displayed in the main chat area whenever a user leaves the chat room. | |
public | width: Number (read, write) |
The width of the ChatBox component on the stage, in pixels. | |
Constructor | |
ChatBox ( ) | |
ChatBox class constructor. Initializes the component. | |
Method Summary | |
public | addEventListener ( type: String, listener: Function ): Void |
Register a listener function in order to receive notification of a ChatBox event. | |
public | clear ( ): Void |
Clear the chat area. | |
public | refreshView ( ): Void |
Refresh the ChatBox view. | |
public | removeEventListener ( type: String, listener: Function ): Void |
Remove a listener from the ChatBox's event dispatcher, to stop receiving notification of an event. | |
public | setPrivateChatUserId ( userId: Number, msgQueue: Array ): Void |
Set the SmartFoxServer ID of the user the ChatBox is listeng to in "private chat" mode. | |
|
The html text displayed before an Administrator message in the main chat area. This header is an html text that comes before each Administrator message displayed in the chat area. See the messageHeader property description to know which placeholders can be used to display dynamic data in the header. #user placeholder is excluded. NOTE: an empty line is always added before and after this alert, to highlight the Administrator message.
|
|
|
A reference to the chat TextArea component. This reference allows you to take control over the chat TextArea mCOM component, to set its properties. Please notice that changing the component size via ActionScript won't affect the rendering on screen, as TextArea is always resized to match the component size. Check the mCOM Flash components documentation for further details.
|
|
|
A reference to the "clear" Button component. This reference allows you to take control over the clear Button mCOM component, to set its properties (for example size). Please notice that if you change the component size, you have to call the refreshView method to rearrange the ChatBox's view accordingly. Check the mCOM Flash components documentation for further details. The clear Button default icon can be customized by adding a custom movieclip with the following linkage property to your application library: it.gotoandplay.smartfoxbits.bits.assets.ClearButtonIcon.
|
|
|
A reference to the ColorPicker component. This reference allows you to take control over the ColorPicker mCOM component, to set its properties. Please notice that if you change the component size, you have to call the refreshView method to rearrange the ChatBox's view accordingly. Check the mCOM Flash components documentation for further details.
|
|
|
Group messages per sender. Setting this property to true enables the messages grouping: if two or more messages in a row come from the same sender, only the first header is displayed.If set to false , each message will have its own header, whether the sender is the same or not.
|
|
|
The height of the ChatBox component on the stage, in pixels. Use this property instead of _height to resize the ChatBox mantaining the inner components' aspect ratio.
|
|
|
The initial message to be displayed inside the message input field. This message disappears as soon as the input field is focused. It should be set to empty if the message field label is made visible.
|
|
|
The text of the label located above the message input field. If left empty, the label doesn't show up in the component.
|
|
|
The html text displayed before a message in the main chat area. The message header is an html text that comes before each new message displayed in the chat area. If groupMessages is set to true , the header is displayed only if the sender of the new message differs from the sender of the previous message.It's possible to show dynamic data in the header using the following placeholders:
|
|
|
A reference to the message input Label component. This reference allows you to take control over the message input Label mCOM component, to set its properties (for example text styling). Please notice that if you change the component size, you have to call the refreshView method to rearrange the ChatBox's view accordingly. Check the mCOM Flash components documentation for further details.
|
|
|
The queue of sent and received messages. The messageQueue property is an array containing all messages sent or received since when the user entered the room. Message headers are excluded. Each item in the queue is an object with the following properties:
|
|
|
A reference to the message TextInput component. This reference allows you to take control over the message TextInput mCOM component, to set its properties (for example text styling). Please notice that if you change the component size, you have to call the refreshView method to rearrange the ChatBox's view accordingly. Check the mCOM Flash components documentation for further details.
|
|
|
The html text displayed before a Moderator message in the main chat area. This header is an html text that comes before each Moderator message displayed in the chat area. See the messageHeader property description to know which placeholders can be used to display dynamic data in the header. #user placeholder is excluded. NOTE: an empty line is always added before and after this alert, to highlight the Moderator message.
|
|
|
Enable/disable the "private chat" mode. Setting this property to true enables the "private chat" mode: public messages are discarded and only private messages coming from the user specified in the privateChatUserId property are displayed.NOTE: also Administrator and Moderator messages and some alerts are discarded.
|
|
|
The SmartFoxServer ID of the user the ChatBox is listeng to in "private chat" mode. This property contains the ID of the user that the ChatBox is currently receiving private messages from. This is a "read-only" property: check the setPrivateChatUserId method to know how to set it.
|
|
|
The set of characters that a user may or may not enter into the message input field. Check the TextField class documentation in the Flash help for description and usage examples of this property. By default, tag delimiters ("<" and ">" characters) are not allowed, to prevent possible html textfields corruption. |
|
The html text displayed in the main chat area when the user joins the chat room. Set this property to an empty text to disable the alert. See the messageHeader property description to know which placeholders can be used to display dynamic data in the alert message. NOTE 1: a line break is always added at the end of this alert.
|
|
|
A reference to the "send" Button component. This reference allows you to take control over the send Button mCOM component, to set its properties (for example size). Please notice that if you change the component size, you have to call the refreshView method to rearrange the ChatBox's view accordingly. Check the mCOM Flash components documentation for further details.
|
|
|
The label of the "send" button.
|
|
Show/hide the "clear" button.
|
|
Show/hide the color picker tool. As the message color is taken from the ColorPicker, even if it is hidden you can set its color accessing the component programmatically, through the colorPicker property.
|
|
Show/hide the focus rectangle around the input field, the color picker and the send button.
|
|
The number of pixels dividing the ChatBox sub-components (message input field, color picker, send button, chat text area).
|
|
The default color of system messages in the main chat area. This property sets the default color of all the system alerts displayed in the main chat area, like messages headers, user enter/leave room alerts, room join alert, administrator messages. You can override this default value for a specific system alert using the font tag in the alert text, setting the color property.
|
|
|
The html text displayed in the main chat area whenever a user enters the chat room. Set this property to an empty text to disable the alert. See the messageHeader property description to know which placeholders can be used to display dynamic data in the alert message. NOTE: a line break is always added at the end of this alert.
|
|
|
The html text displayed in the main chat area whenever a user leaves the chat room. Set this property to an empty text to disable the alert. See the messageHeader property description to know which placeholders can be used to display dynamic data in the alert message. NOTE: a line break is always added at the end of this alert.
|
|
|
The width of the ChatBox component on the stage, in pixels. Use this property instead of _width to resize the ChatBox mantaining the inner components' aspect ratio.
|
|
|
ChatBox class constructor. Initializes the component. |
|
Register a listener function in order to receive notification of a ChatBox event. You can register to events fired by the ChatBox component, in case you need to be notified to execute your own code. The ChatBox dispatches the following events: If you no longer need an event listener, remove it by calling the removeEventListener method. NOTE: you should use the
| ||||||
|
|
Clear the chat area. Call this method to empty the chat TextArea and the message TextInput and reset the messages queue. |
|
Refresh the ChatBox view. If you change the size of the ChatBox's inner components, you have to call this method to rearrange the ChatBox's view accordingly. |
|
Remove a listener from the ChatBox's event dispatcher, to stop receiving notification of an event.
| ||||||
|
|
Set the SmartFoxServer ID of the user the ChatBox is listeng to in "private chat" mode. Use this method to set the ID of the user the ChatBox is currently sending/receiving private messages to/from. If the userId parameter is greater than -1, the privateChatMode is set to true even if this wasn't done before, and the ChatBox interface is enabled; if userId is equal to -1, the ChatBox remains in "private chat" mode, but the interface is disabled.This method also accepts an array as (optional) second parameter, containing a list of messages to be displayed in the ChatBox immediately. This is useful in case you need to manage several private conversations in one single ChatBox (like in the SmartFoxBits' UserList component, for example): each time you change user, you can keep track of the current conversation through the messageQueue property and then pass it back to this method when re-enabling the private chat with a previous user. NOTE: the msgQueue parameter must be an array with the same data structure of the messageQueue property.
| ||||||
|
The SmartFoxBits' ChatBox component enables public interaction among users inside a server room, allowing them to write and read public text messages, or private cross-room interaction, by means of private text messages. The component contains a textfield to input the message, a color picker to set the message color, a send button and a text area where sent and received messages are displayed. As for all the other SmartFoxBits components, these items are based on the mCOM Flash components. You can read more about these components and their features here.
The ChatBox can be customized by hiding the color picker tool and setting the input field label, its initial message and the button label. You can also set your custom system messages that appear inside the main chat area, like the header in front of each user message, the alerts in case of user entering/leaving the chat room, the Administrator and Moderator messages' headers.
All this messages can be entered using html formatting, and support a number of parameters to display dynamic data (user name, room name, time, date).