import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.media.Camera;
import flash.events.MouseEvent;
import flash.net.NetStream;
import flash.media.Microphone;
import flash.utils.ByteArray;
const SERVER_ADDRESS:String = "rtmfp://p2p.rtmfp.net/";
const DEVELOPER_KEY:String = "key";
var conn:NetConnection;
var streamOut:NetStream;
var streamIn:NetStream;
var myPeerID:String;
var farID:String;
function connect(){
clearInterval(myInterval);
conn = new NetConnection();
conn.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
conn.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErr);
conn.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
conn.connect(SERVER_ADDRESS+DEVELOPER_KEY);
}
function asyncErr(event:AsyncErrorEvent){
trace("esyncerror:"+event);
}
function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
function initOutStream():void{
trace("initOutStream\n");
streamOut = new NetStream(conn,NetStream.DIRECT_CONNECTIONS);
streamOut.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
streamOut.publish("media");
var cam:Camera = Camera.getCamera();
camOut.attachCamera(cam);
streamOut.attachCamera(cam);
streamOut.attachAudio(Microphone.getMicrophone());
var streamOutClient:Object = new Object();
streamOutClient.onPeerConnect = function(farStream:NetStream):Boolean{
initInStream(farStream.farID);
return true;
}
}
function pal(event:MouseEvent):void{
initInStream(farID);
}
function initInStream(farID:String):void{
trace("initInStream: ");
streamIn = new NetStream(conn,farID);
streamIn.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
streamIn.play("media");
streamIn.client = this;
camIn.attachNetStream(streamIn);
}
//netstatus function
function netStatus(event:NetStatusEvent):void{
trace(event.info.code);
switch(event.info.code){
case "NetConnection.Connect.Success":
myPeerID = conn.nearID;
txtMyPeerID.text = myPeerID;
send_peer();
initOutStream();
break;
case "NetStream.Connect.Success":
break;
case "NetStream.Connect.Closed":
conn.close(); remove_status(); streamOut.close();
camOut.attachCamera(null);
gotoAndStop(4);
break;
case "NetStream.Play.Start":
if(farID == null){
trace('play start:'+event.target.peerStreams[0].farID);
txtFarPeerID.text = event.target.peerStreams[0].farID;
farID = event.target.peerStreams[0].farID;}
break;
}
}
//sending mypeedid and call_to_id
function send_peer(){
if(call_to_id){
var urlreq = new URLRequest("http://somescript.php");
urlreq.method = URLRequestMethod.POST;
var urlvars = new URLVariables();
urlvars.call_to = call_to_id;
urlvars.peerid = myPeerID;
urlreq.data = urlvars;
var loader:URLLoader = new URLLoader(urlreq);
loader.addEventListener(Event.COMPLETE, confirm);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlreq);
}
}
function confirm(event:Event){
trace(event.target.data.s);
}
function remove_status(){
farID = null;
var urlreq = new URLRequest("http://some_script.php");
urlreq.method = URLRequestMethod.POST;
var urlvars = new URLVariables();
urlvars.remove_my = idd;
urlvars.remove_to = call_to_id;
urlreq.data = urlvars;
var loader:URLLoader = new URLLoader(urlreq);
loader.addEventListener(Event.COMPLETE, remove_complete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlreq);
}
function remove_complete(event:Event){
trace(event.target.data.aa);
}
// eventhandler for buttons
init.addEventListener(MouseEvent.CLICK,pal);
end_call.addEventListener(MouseEvent.CLICK,call_end);
function call_end(event:MouseEvent){
conn.close(); remove_status();
//streamOut.close();
camOut.attachCamera(null);
gotoAndStop(4);
}
errors::
1) Error #1069: Property startTransmit not found on flash.net.NetStream and there is no default value.
2)Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback startTransmit. error=ReferenceError: Error #1069: Property startTransmit not found on flash.net.NetStream and there is no default value.
when person make a call i m sending neerid in database to person he wants to call, other person receives that neerid and initInStream(farID:String); function is initiated , streamout and streamin starts. i receive farid in person who is making call but when i click on receive to start streamin above 2 error comes to person who is receiving call
I think that your speaking about Adobe Labs : Cirrus Sample Application. So, for your first error, you can take a look here, for the second one, you can just add a
AsyncErrorEvent
listener for yourNetStream
as you did with yourNetConnection
: