Client-Side Communication ActionScript > SharedObject.connect |
![]() ![]() ![]() |
SharedObject.connect
Availability
![]() |
Flash Player 6. |
![]() |
Flash Communication Server MX. |
Usage
myRemoteSharedObject
.connect(myRTMPConnection
)
Parameters
myRTMPConnection
A NetConnection object that is using the Real-Time Messaging Protocol (RTMP) to communicate with the Flash Communication Server.
Returns
A Boolean value of true
if the connection was successfully completed, false
otherwise.
Description
Method; connects to a remote shared object on the Flash Communication Server through the specified connection. Use this method after issuing SharedObject.getRemote
. After a successful connection, the SharedObject.onSync
event handler is invoked.
Before attempting to work with a remote shared object, you should first check for a return value of true
, indicating a successful connection, and then wait until you receive a result from the function you have assigned to SharedObject.onSync
. If you fail to do so, any changes you make to the object locallybefore SharedObject.onSync
is invokedmay be lost.
Note: SharedObject.onSync
is not invoked if this call returns false
.
Example
The following example connects to a shared object and initializes it.
function getMaster() { trace("getMaster called"); master = SharedObject.getRemote("master", con.uri, true); connVal = master.connect(con); if (connVal) print("Connection was successful"); else print("Unable to connect the shared object with the given NetConnection object"); master.onSync = function (listVal) { getPlayList(); trace("SO: " + so.data[currentPlaylist]); } }
See also
NetConnection (object), SharedObject.getRemote
, SharedObject.onSync
![]() ![]() ![]() |