错误#1069:在flash.net.NetStream上找不到属性startTransmit,并且没有默认值

时间:2014-12-05 12:30:14

标签: actionscript-3 adobe p2p adobe-cirrus

    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);
            }

错误::

1)错误#1069:在flash.net.NetStream上找不到属性startTransmit,并且没有默认值。

2)错误#2044:未处理的AsyncErrorEvent:。 text =错误#2095:flash.net.NetStream无法调用回调startTransmit。 error = ReferenceError:错误#1069:在flash.net.NetStream上找不到属性startTransmit,并且没有默认值。

当人打电话我将数据库中的neerid发送给他想要呼叫的人时,其他人会收到该neerid和initInStream(farID:String);函数启动,streamout和streamin启动。我接到正在打电话的人,但是当我点击接收开始流上面2错误来到接听电话的人

1 个答案:

答案 0 :(得分:1)

我认为你在谈论 Adobe Labs : Cirrus Sample Application。因此,对于您的第一个错误,您可以查看here,对于第二个错误,您可以像AsyncErrorEvent一样为NetStream添加NetConnection听众}:

ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(e:AsyncErrorEvent){

    ...

})