Пример из хелпа. В верху раздела есть ссылки на хелп.
Код AS3:
package {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.utils.setTimeout;
public class TestExample extends Sprite
{
var nc:NetConnection = new NetConnection();
var ns1:NetStream;
var ns2:NetStream;
var vid:Video = new Video(300,300);
var obj:Object = new Object();
public function TestExample() {
nc.objectEncoding = 0;
nc.addEventListener("netStatus", onNCStatus);
nc.connect("rtmp://localhost/FlashVideoApp");
addChild(vid);
}
function onNCStatus(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
trace("You've connected successfully");
ns1 = new NetStream(nc);
ns2 = new NetStream(nc);
ns1.client = new CustomClient();
ns1.publish("dummy", "live");
ns2.play("dummy");
ns2.client = new CustomClient();
vid.attachNetStream(ns2);
setTimeout(sendHello, 3000);
break;
case "NetStream.Publish.BadName":
trace("Please check the name of the publishing stream" );
break;
}
}
function sendHello():void {
ns1.send("myFunction", "hello");
}
}
}
class CustomClient {
public function myFunction(event:String):void {
trace(event);
}
}
Т.е на публикующем NetStream вызываем send();. На принимающем возникает функция обратного вызова, но названием переданным в send();
Код AS3:
function sendHello():void {
ns1.send("myFunction", "hello");
}
Вызвали send(); c названием функции обратного вызова "myFunction" передаем объект, в данном случае строку "hello"
Код AS3:
class CustomClient {
public function myFunction(event:String):void {
trace(event);
}
}
здесь приняли объект (строку 'hello');