View comments | RSS feed

NetStream.send()

Availability

Usage

public send(handlerName : String [,p1, ...,pN]) : Void

Parameters

handlerName A string value that identifies the message; also the name of the ActionScript handler to receive the message. The handler name can be only one level deep (that is, it can't be of the form parent/child) and is relative to the stream object.

NOTE

 

Do not use a reserved term for a handler name. For example, my_ns.send("close") will fail.

p1, ...,pN Optional parameters that can be of any type. They are serialized and sent over the connection, and the receiving handler receives them in the same order. If a parameter is a circular object (for example, a linked list that is circular), the serializer handles the references correctly.

Returns

Nothing.

Description

Method; broadcasts a message on the specified stream to all subscribing clients. This method is available only to the publisher of the specified stream.

To process and respond to the message, create a handler in the format my_ns.HandlerName.

Flash Player does not serialize methods or their data, object prototype variables, or non-enumerable variables. Also, for movie clips, Flash Player serializes the path but none of the data.

Example

The sending client has the following script:

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myServer.myDomain.com/appName/appInstance");
var my_ns:NetStream = new NetStream(my_nc);
my_ns.publish("slav", "live");    
my_ns.send("Fun", "this is a test");    //Fun is the handler name.

The receiving client's script looks something like this:

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://myServer.myDomain.com/appName");
my_ns = new NetStream(my_nc);
my_ns.play("slav", -1, -1);

my_ns.Fun = function(str) { //Fun is the handler name.
    trace (str);
}

Comments


gnic said on Jun 20, 2006 at 10:28 PM :
I just heard on FlashComm list that NetStream.send() actually means it is setting a "cuepoint", but the docs just say it's a "message". This is confusing to me because i was led to believe that cuepoints were something added just as a feature to FLVPlayback component. If the NetStream.send() is actually sending a cuepoint object, then it should say "cuepoint" in the docs... not just "message"... which is very misleading.
No screen name said on Aug 4, 2007 at 9:30 AM :
This exemple code doesn't work at all :( dont know what is worng

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000593.html