Skip to main content
June 8, 2011
Answered

Error 2044 + 1096?

  • June 8, 2011
  • 1 reply
  • 4593 views

Why does this error happen?

function Function() {}
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
    at MinCam()

My code

package
{
  import flash.display.Sprite;
  import flash.media.Camera;
  import flash.media.Microphone;
  import flash.media.Video;
  import flash.net.NetConnection;
  import flash.net.NetStream;
  import flash.net.ObjectEncoding;
  import flash.events.NetStatusEvent;

  public class MinCam extends Sprite
  {
        private var cam:Camera;
        private var mic:Microphone;
        private var vid1:Video;
        private var vid2:Video;
        private var nc:NetConnection;
        private var nsOut:NetStream;
        private var nsIn:NetStream;
        private var rtmpNow:String;
        private var msg:Boolean;

        public function MinCam ()
        {
             cam = Camera.getCamera();
             mic = Microphone.getMicrophone();
             rtmpNow = "rtmp://localhost/live";
               nc = new NetConnection
               nc.addEventListener(NetStatusEvent.NET_STATUS, connected)

             //Camera Settings
             cam.setKeyFrameInterval (15);
             cam.setMode (240,180,15,false);
             cam.setMotionLevel (35,3000);
             cam.setQuality (40000 / 8,0);

             //Microphone Settings
             mic.gain = 85;
             mic.rate= 11;
             mic.setSilenceLevel (25,1000);
             mic.setUseEchoSuppression (true);

             //Connect
             nc.connect (rtmpNow);

             //Video Setup
             vid1=new Video(cam.width,cam.height);
             vid2=new Video(cam.width,cam.height);
             addChild (vid1);
             vid1.x=10,vid1.y=20;
             addChild (vid2);
             vid2.x=vid1.width+15,vid2.y=20;

             //Attach local video and camera
             vid1.attachCamera (cam);

           
        }
      
          public function connected(Event:NetStatusEvent):void
        {
               trace("something happend")
            switch (Event.info.code)
            {
                case "NetConnection.Connect.Success":
                nsOut = new NetStream(nc);
                 nsIn = new NetStream(nc);
                 trace(connected)
                 nsOut.attachAudio (mic);
                 nsOut.attachCamera (cam);
                 nsOut.publish ("camstream");
                 vid2.attachNetStream (nsIn);
                 nsIn.play ("camstream");
                break;
            }
        }
      
  }
}

    This topic has been closed for replies.
    Correct answer amit_kr

    Can anyone please help me?

    (I know i am very bad at error handling)


    Below is the working code:

    package
    {
         import flash.display.Sprite;
         import flash.media.Camera;
         import flash.media.Microphone;
         import flash.media.Video;
         import flash.net.NetConnection;
         import flash.net.NetStream;
         import flash.net.ObjectEncoding;
         import flash.events.NetStatusEvent;
         import flash.events.AsyncErrorEvent;

         public class MinCam extends Sprite
         {
                private var cam:Camera;
                private var mic:Microphone;
                private var vid1:Video;
                private var vid2:Video;
                private var nc:NetConnection;
                private var ns:NetStream;
                private var nsOut:NetStream;
                private var nsIn:NetStream;
                private var rtmpNow:String;
                private var msg:Boolean;
                private var customClient:Object;

                public function MinCam()
                {    
                   cam = Camera.getCamera();
                   mic = Microphone.getMicrophone();
                   rtmpNow = "rtmp://10.192.22.20/live";
                   nc = new NetConnection();
                   nc.addEventListener(NetStatusEvent.NET_STATUS, connected)
                   nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncHandler);
                  
                   //Camera Settings
                   cam.setKeyFrameInterval (15);
                   cam.setMode (240,180,15,false);
                   cam.setMotionLevel (35,3000);
                   cam.setQuality (40000 / 8,0);
               
                  //Microphone Settings
                   mic.gain = 85;
                   mic.rate= 11;
                   mic.setSilenceLevel (25,1000);
                   mic.setUseEchoSuppression (true);
                  
                  //Connect
                  nc.connect (rtmpNow);
                   
                 //Video Setup
                 vid1=new Video(cam.width,cam.height);
                 vid2=new Video(cam.width,cam.height);
                 addChild (vid1);
                 vid1.x=10,vid1.y=20;
                 addChild (vid2);
                 vid2.x=vid1.width+15,vid2.y=20;
               
                 //Attach local video and camera
                 vid1.attachCamera (cam);
                }

              public function connected(Event:NetStatusEvent):void
              {
                trace("something happend");
                switch (Event.info.code)
                {
                    case 'NetConnection.Connect.Success':
                    nsOut = new NetStream(nc);
                    nsIn = new NetStream(nc);
                    customClient = new Object();
                    nsIn.client = customClient;
                    customClient.onBWDone = onBWDoneHandler;
                    trace("connected");
                    nsOut.attachAudio (mic);
                    nsOut.attachCamera (cam);
                    nsOut.publish ('camstream');
                    vid2.attachNetStream (nsIn);
                    nsIn.play ('camstream');
                    break;
                }
              }

              function asyncHandler(Event:AsyncErrorEvent):void
              {
                   trace("In asyncHandler");
              }
               
              public function onBWDoneHandler( eventObj:Object ):void
              {
                   trace("** onBWDone :"  + Number(eventObj) + " kbps");
              }
      }

    }

    1 reply

    Adobe Employee
    June 8, 2011

    nc.addEventListener("asyncError", asyncHandler);

    function asyncHandler(event:AsyncErrorEvent): void {
    trace("In asyncHandler");
    }

    ns.client = customClient;

    customClient.onBWDone = onBWDoneHandler;

    function onBWDoneHandler( eventObj:Object ):void {
    displayMessage("** onBWDone : " + Number(eventObj) + " kbps");
    }

    You need to handle them as above.

    June 8, 2011

    I did what you said and now the error is 1046: Type was not found or was not a compile-time constant: AsyncErrorEvent.``

    My Code:

    package
    {
      import flash.display.Sprite;
      import flash.media.Camera;
      import flash.media.Microphone;
      import flash.media.Video;
      import flash.net.NetConnection;
      import flash.net.NetStream;
      import flash.net.ObjectEncoding;
      import flash.events.NetStatusEvent;

      public class MinCam extends Sprite
      {
            private var cam:Camera;
            private var mic:Microphone;
            private var vid1:Video;
            private var vid2:Video;
            private var nc:NetConnection;
            private var nsOut:NetStream;
            private var nsIn:NetStream;
            private var rtmpNow:String;
            private var msg:Boolean;

            public function MinCam ()
            {
                 cam = Camera.getCamera();
                 mic = Microphone.getMicrophone();
                 rtmpNow = "rtmp://localhost/live";
                   nc = new NetConnection
                   nc.addEventListener(NetStatusEvent.NET_STATUS, connected)
                   nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncHandler);
                   ns.client = customClient;

                   customClient.onBWDone = onBWDoneHandler;

                 //Camera Settings
                 cam.setKeyFrameInterval (15);
                 cam.setMode (240,180,15,false);
                 cam.setMotionLevel (35,3000);
                 cam.setQuality (40000 / 8,0);

                 //Microphone Settings
                 mic.gain = 85;
                 mic.rate= 11;
                 mic.setSilenceLevel (25,1000);
                 mic.setUseEchoSuppression (true);

                 //Connect
                 nc.connect (rtmpNow);

                 //Video Setup
                 vid1=new Video(cam.width,cam.height);
                 vid2=new Video(cam.width,cam.height);
                 addChild (vid1);
                 vid1.x=10,vid1.y=20;
                 addChild (vid2);
                 vid2.x=vid1.width+15,vid2.y=20;

                 //Attach local video and camera
                 vid1.attachCamera (cam);

               
            }
          
              public function connected(Event:NetStatusEvent):void
            {
                   trace("something happend")
                switch (Event.info.code)
                {
                    case "NetConnection.Connect.Success":
                    nsOut = new NetStream(nc);
                     nsIn = new NetStream(nc);
                     trace(connected)
                     nsOut.attachAudio (mic);
                     nsOut.attachCamera (cam);
                     nsOut.publish ("camstream");
                     vid2.attachNetStream (nsIn);
                     nsIn.play ("camstream");
                    break;
                }
            }

              function asyncHandler(Event:AsyncErrorEvent):void
              {
                   trace("In asyncHandler");
              }
              
              public function onBWDoneHandler( eventObj:Object ):void
              {
                   displayMessage("** onBWDone : " + Number(eventObj) + " kbps");
              }
          
      }
    }

    Adobe Employee
    June 9, 2011

    Include the below Class:

    import flash.events.AsyncErrorEvent;