Previous | Next | Frames | No Frames |
Summary: Field | Property | Contructor | Method | Detail: Field | Property | Contructor | Method |
MovieClip | +--it.gotoandplay.smartfoxbits.bits.Connector
If you use this component in conjunction with other SmartFoxBits, make sure it's instantiated before the other components. This is required because the other components register to the Connector's event handler in order to communicate with SmartFoxServer.
To achieve this you should place the Connector on a frame and the other components on the following frame(s). If you need to put all the SmartFoxBits on a single frame, just make sure that the Connector is on the lowest layer of the timeline, and set the "Load order" option in the Flash Publish Settings to "Bottom up".
To make the component connect to SmartFoxServer as soon as it is instantiated at run-time, set the auto-connect property to true
.
import it.gotoandplay.smartfoxbits.bits.Connector var connector_mc:Connector = Connector(attachMovie("Connector", "connector_mc", 0)) connector_mc.connect()
NOTE 1: importing the it.gotoandplay.smartfoxbits.bits.Connector class and casting the Connector's movieclip to it is useful if you intend to use a development tool having code-completion features. Otherwise this is enough:
var connector_mc = attachMovie("Connector", "connector_mc", 0)NOTE 2: in the following examples connector_mc represents the Connector instance name.
Property Summary | |
public | autoConnect: Boolean (read, write) |
Enable/disable the Connector's "auto-connect" feature. | |
public | connectedMessage: String (read, write) |
The message displayed by the Connector's label after a successful connection to SmartFoxServer. | |
public | connectingMessage: String (read, write) |
The message displayed by the Connector's label during connection attempt. | |
public | connection: SmartFoxClient (read-only) |
A reference to the SmartFoxClient class instance. | |
public | connectionFailedMessage: String (read, write) |
The message displayed by the Connector's label if the connection attempt failed. | |
public | connectionLostMessage: String (read, write) |
The message displayed by the Connector's label if the connection with SmartFoxServer was lost. | |
public | debug: Boolean (read, write) |
Enable/disable the Connector's debugging feature. | |
public | height: Number (read, write) |
The height of the Connector component on the stage, in pixels. | |
public | isConnected: Boolean (read-only) |
The current connection status. | |
public | labelPlacement: String (read, write) |
The position of the Connector's label, to the right or to the left of the led. | |
public | notConnectedMessage: String (read, write) |
The message displayed by the Connector's label before attempting to connect to SmartFoxServer. | |
public | serverIpAddress: String (read, write) |
The IP address of the server on which the SmartFoxServer instance is running. | |
public | serverPort: Number (read, write) |
The TCP port of the server on which the SmartFoxServer instance is running. | |
public | spacing: Number (read, write) |
The number of pixels between the Connector's label and led. | |
public | statusLabel: Label (read-only) |
A reference to the Connector's status label. | |
public | width: Number (read, write) |
The width of the Connector component on the stage, in pixels. | |
Constructor | |
Connector ( ) | |
Connector class constructor. Initializes the component at author-time. | |
Method Summary | |
public | addEventListener ( type: String, listener: Function ): Void |
Register a listener function in order to receive notification of a SmartFoxServer event. | |
public | connect ( ): Void |
Establish a connection with SmartFoxServer. | |
public | refreshView ( ): Void |
Refresh the Connector's view. | |
public | removeEventListener ( type: String, listener: Function ): Void |
Remove a listener from the Connector's event dispatcher, to stop receiving notification of an event. | |
|
Enable/disable the Connector's "auto-connect" feature. When the "auto-connect" feature is turned on, the Connector sets up the communication with SmartFoxServer as soon as it's instantiated on the stage. Otherwise the connection must be started manually calling the connect method.
|
|
|
The message displayed by the Connector's label after a successful connection to SmartFoxServer.
|
|
|
The message displayed by the Connector's label during connection attempt.
|
|
|
A reference to the SmartFoxClient class instance. This reference allows you to invoke API methods to send server commands and requests, and handle events sent by the server. You can use this reference if you need to set up a custom dialogue with the server, whithout using other SmartFoxBits components' event dispatchers.
|
|
The message displayed by the Connector's label if the connection attempt failed.
|
|
|
The message displayed by the Connector's label if the connection with SmartFoxServer was lost.
|
|
|
Enable/disable the Connector's debugging feature. When the debug is turned on, the messages exchanged with SmartFoxServer by all the SmartFoxBits components are traced in the Flash Output panel during the movie testing.
|
|
|
The height of the Connector component on the stage, in pixels. Use this property instead of _height to mantain the led's aspect ratio.This property doesn't affect the aspect of the component on the stage: the led and the label are vertically centered on respect of the given height .
|
|
|
The current connection status.
|
|
|
The position of the Connector's label, to the right or to the left of the led. Whatever the placement of the label is, the displayed text is always aligned so that it starts or ends at the distance from the led specified in the property. So, if the label is placed to the left of the led, then the text is right-aligned inside its textbox.
|
|
|
The message displayed by the Connector's label before attempting to connect to SmartFoxServer.
|
|
|
The IP address of the server on which the SmartFoxServer instance is running.
|
|
|
The TCP port of the server on which the SmartFoxServer instance is running.
|
|
|
The number of pixels between the Connector's label and led.
|
|
|
A reference to the Connector's status label. This reference allows you to take control over the status Label mCOM component, to set its properties (for example text styling). Please notice that if you change the component height, you have to call the refreshView method to rearrange the Connector's view accordingly. Check the mCOM Flash components documentation for further details.
|
|
|
The width of the Connector component on the stage, in pixels. Use this property instead of _width to mantain the led's aspect ratio and resize the label's textbox accordingly. If the label's text exceeds the width value, clipping occurs.
|
|
|
Connector class constructor. Initializes the component at author-time. |
|
Register a listener function in order to receive notification of a SmartFoxServer event. You can register to events fired by SmartFoxServer using the Connector, in case you need to be notified to execute additional code for your purposes. Using the Connector's addEventListener method instead of the standard way of registering to SmartFoxServer events (for example: smartFoxClientInstance.onConnection = Delegate.create(this, myEventListener) ) lets you have different listeners for the same events: this is useful in case you need to build a modular architecture. As all SmartFoxBits componentents rely on this concept, if you plan to use the Connector in conjunction with other SmartFoxBits components, it's mandatory to use this method to listen to events.See the it.gotoandplay.smartfoxbits.events.SFSEvent class for the event types dispatched by the Connector and for details on the parameters contained in the event object. If you no longer need an event listener, remove it by calling the removeEventListener method. NOTE: use the
| ||||||
|
|
Establish a connection with SmartFoxServer. When this method is called, the Connector establishes a communication with SmartFoxServer using the specified IP address and TCP port. If the auto-connect feature is turned on, this method is called by the component itself as soon as it's instantiated at run-time.
|
|
|
Refresh the Connector's view. If you change the size of the Connector's inner components, you have to call this method to rearrange the Connector's view accordingly. |
|
Remove a listener from the Connector's event dispatcher, to stop receiving notification of an event.
| ||||||
|
The SmartFoxBits' Connector component lets you establish a connection to a SmartFoxServer instance running on a specified IP address and TCP port.
The Connector has built-in led and label to display the connection status. The label can be customized by setting the status message, its placement (to the led's right or left) and the distance from the led. You can also customize the label text style accessing the Label component through the statusLabel property.
The default led can be substituted with a custom led from your application library; just set the linkage of your custom led movieclip to: it.gotoandplay.smartfoxbits.bits.assets.LedIcon. To display all the connection statuses properly, the custom led movieclip must have the following structure:
NOTE 1: use the same frame labels (case-sensitive).
NOTE 2: add a
stop()
action in each frame.