Skip to main content
July 6, 2011
Question

Error 1046

  • July 6, 2011
  • 2 replies
  • 665 views

Please help and fix my mistakes

the error is:

1046: Type was not found or was not a compile-time constant: MouseEvent.

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;
     import flash.events.AsyncErrorEvent;
      import flash.system.Security;
      import flash.system.SecurityPanel;

     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()
            {   
               mic.addEventListener(MouseEvent.CLICK, settings);
                                   
                  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);
             
               //Camera Settings
                  cam.keyFrameInterval = 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;
            }
          }

          public function asyncHandler(Event:AsyncErrorEvent):void
          {
               trace("In asyncHandler");
          }
          
          public function onBWDoneHandler( eventObj:Object ):void
          {
               trace("** onBWDone :"  + Number(eventObj) + " kbps");
          }
            public function settings(Event:MouseEvent):void
            {
                 Security.showSettings(SecurityPanel.MICROPHONE);
            }
  }

}

    This topic has been closed for replies.

    2 replies

    July 6, 2011

    Please Lock

    Participating Frequently
    July 6, 2011

    Hi nhl_rules

    For better turnaround for these kind of queries i would recommend you to post on AS3 forums here : http://forums.adobe.com/community/flash/flash_actionscript3

    July 6, 2011

    please help me close up this thread