Detailed instructions for use are in the User's Guide.
[. . . ] Server-Side Communication ActionScript Dictionary
Macromedia Flash Communication Server MX
TM
TM
macromedia
®
Trademarks Afterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware Attain, Authorware Interactive Studio, Authorware Star, Authorware Synergy, Backstage, Backstage Designer, Backstage Desktop Studio, Backstage Enterprise Studio, Backstage Internet Studio, Design in Motion, Director, Director Multimedia Studio, Doc Around the Clock, Dreamweaver, Dreamweaver Attain, Drumbeat, Drumbeat 2000, Extreme 3D, Fireworks, Flash, Fontographer, FreeHand, FreeHand Graphics Studio, Generator, Generator Developer's Studio, Generator Dynamic Graphics Server, Knowledge Objects, Knowledge Stream, Knowledge Track, Lingo, Live Effects, Macromedia, Macromedia M Logo & Design, Macromedia Flash, Macromedia Xres, Macromind, Macromind Action, MAGIC, Mediamaker, Object Authoring, Power Applets, Priority Access, Roundtrip HTML, Scriptlets, SoundEdit, ShockRave, Shockmachine, Shockwave, Shockwave Remote, Shockwave Internet Studio, Showcase, Tools to Power Your Ideas, Universal Media, Virtuoso, Web Design 101, Whirlwind and Xtra are trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words or phrases mentioned within this publication may be trademarks, servicemarks, or tradenames of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] These parameters are sent as connection parameters to the application. onConnect event handler for RTMP connections. For AMF connections to application servers, any RTMP parameters are ignored.
Returns
For RTMP connections, a Boolean value of true for success; false otherwise. For AMF connections to application servers, true is always returned.
Description
Method; connects to the host. The host URI has the following format: [protocol://]host[:port]/appName[/instanceName] For example, the following are legal URIs:
http://appServer. mydomain. com/webApp rtmp://rtserver. mydomain. com/realtimeApp
It is good practice to write an application. onStatus callback function and check the NetConnection. isConnected property for RTMP connections to see whether a successful connection was made. For Action Message Format connections, check
NetConnection. onStatus.
Example
This example creates an RTMP connection to another Flash Communication Server for the myConn instance of NetConnection:
myConn = new NetConnection(); myConn. connect("rtmp://tc. foo. com/myApp/myConn");
The following example creates an AMF connection to an application server for the myConn instance of NetConnection:
myConn = new NetConnection(); myConn. connect("http://www. xyz. com/myApp/");
NetConnection. isConnected
Availability
Flash Communication Server MX.
38
Usage
myNetConnection. isConnected
Description
Property (read-only); a Boolean value that indicates whether a connection has been made. It is set to true if there is a connection to the server. It's a good idea to check this property value in the onStatus callback function. This property is always true for AMF connections to application servers.
Example
This example uses NetConnection. isConnected inside an onStatus definition to check if a connection has been made:
nc = new NetConnection(); nc. connect("rtmp://tc. foo. com/myApp"); nc. onStatus = function(infoObj){ if (info. code == "NetConnection. Connect. Success" && nc. isConnected){ trace("We are connected"); } };
NetConnection. onStatus
Availability
Flash Communication Server MX.
Usage
myNetConnection. onStatus = function(infoObject) { // Your code here }
Parameters
infoObject An information object. For details about this parameter, see the Appendix, "Server-Side Information Objects, " on page 67.
Returns
Nothing.
Description
Event handler; invoked every time the status of the NetConnection object changes. For example, if the connection with the server is lost in an RTMP connection, the NetConnection. isConnected property is set to false, and NetConnection. onStatus is invoked with a status message of NetConnection. Connect. closed. For AMF connections, NetConnection. onStatus is used only to indicate a failed connection. Use this event handler to check for connectivity.
Server-Side Communication ActionScript
39
Example
This example defines a function for the onStatus handler that outputs messages to indicate whether the NetConnection was successful:
nc = new NetConnection(); nc. onStatus = function(info){ if (info. code == "NetConnection. Connect. Success") { _root. gotoAndStop(2); } else { if (!nc. isConnected){ _root. gotoAndStop(1); } } };
NetConnection. uri
Availability
Flash Communication Server MX.
Usage
myNetConnection. uri
Description
Property (read-only); A string indicating the URI that was passed by the NetConnection. connect method. This property is set to null before a call to NetConnection. connect or after NetConnection. close is called.
setInterval
Availability
Flash Communication Server MX.
Usage
setInterval(function, interval[, p1, . . . , pN]); setInterval(object, methodName, interval[, p1, . . . , pN]);
Parameters
function
The name of a defined ActionScript function or a reference to an anonymous An object derived from the ActionScript Object object. The name of the method to call on object. The time (interval) between calls to function, in milliseconds. Optional parameters passed to function.
function.
object methodName interval
p1, . . . , pN
Returns
A unique ID for this call. If the interval is not set, the method returns -1.
40
Description
Method (global); continually calls a function or method at a specified time interval until the clearInterval method is called. This method allows a server-side script to run a generic routine. The setInterval method returns a unique ID that you can pass to the clearInterval method to stop the routine.
Note: Standard JavaScript supports an additional usage for the setInterval method, setInterval(stringToEvaluate, timeInterval), which is not supported by Server-Side Communication ActionScript.
Example
The following example uses an anonymous function to send the message "interval called" to the server log every second:
setInterval(function(){trace("interval called");}, 1000);
The following example also uses an anonymous function to send the message "interval called" to the server log every second, but it passes the message to the function as a parameter:
setInterval(function(s){trace(s);}, 1000, "interval called");
The following example uses a named function, callback1, to send the message "interval called" to the server log:
function callback1(){ trace("interval called"); } setInterval(callback1, 1000);
The following example also uses a named function, callback2, to send the message "interval called" to the server log, but it passes the message to the function as a parameter:
function callback2(s){ trace(s);} setInterval(callback2, 1000, "interval called");
SharedObject (object)
Shared objects let you share data between multiple client movies in real time. Shared objects can be persistent on the server and you can think of these objects as real-time data transfer devices. You can also use the client-side ActionScript SharedObject object to create shared objects on the client. [. . . ] lineno: line number where the error occurred. linebuf: source code of the offending line. The ActionScript engine has encountered a runtime warning. In addition to the standard infoObject properties, the following properties are set: filename: name of the offending ASC file. [. . . ]