mardi 14 mars 2017

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

I am new at this plateform and after a lot of search, I am unable to resolve this problem. My code is show error on "VideoContainer" in one project but in other project, it is working fine.

<VideoContainer id="videoDisplay" x="-2" y="0" width="640" height="480" click="hideCanvas()"/>

enter image description here

<?xml version="1.0" encoding="utf-8"?>

<mx:WindowedApplication xmlns:mx="http://ift.tt/1aBfKeP" 
                        xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns="*"
     viewSourceURL="srcview/index.html"
                paddingLeft="0"
                paddingRight="0"
                paddingTop="0"
                paddingBottom="0"
                layout="absolute"
                width="645" height="500"
                creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.events.AsyncErrorEvent;
            import flash.media.*;
            import flash.media.H264Level;
            import flash.media.H264VideoStreamSettings;
            import flash.media.Video;
            import flash.media.VideoCodec;
            import flash.media.VideoStreamSettings;
            import flash.net.ObjectEncoding;

            import mx.controls.*;
            import mx.controls.Alert;
            import mx.controls.Label;
            import mx.controls.Menu;
            import mx.events.*;
            import mx.events.MenuEvent;
            import mx.events.SliderEvent;

            private var microphone:Microphone;
            private var camera:Camera;
            private var video:Video;

            private var h264Settings:H264VideoStreamSettings = new H264VideoStreamSettings();

            [Bindable]
            public var nc:NetConnection;
            public var ncl:NetStream;
            public var ncr:NetStream;
            private var mic:Microphone;
            private var customClient:Object;

            [Bindable]
            public var isSender:Boolean;

            private function init():void
            {
                    nc = new NetConnection();
                    nc.objectEncoding = ObjectEncoding.AMF0;  //pass binary data between two servers.
                    nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
                nc.connect( "rtmp://wjzoiqyosa.rtmphost.com/fms01");
                nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncHandler);
            }

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

            public function netStatusHandler( event:NetStatusEvent ):void
            {
                switch( event.info.code ) {
                    case "NetConnection.Connect.Success":
                        // Connection succeeded now create components
                        connectComponents();
                        // Change to Video view
                        //vsMain.selectedChild = pnlVideo;
                    break;
                    case "NetConnection.Connect.Rejected":
                        Alert.show( "User limit exceed", "Restricted Usage" );
                    break;                  
                }
            }
            public function connectComponents():void
            {

                init2();
            }

            public var bandwidth:int;
            public var framerate:int;
            public var picture:int;
            public var keyframe:int;

            private function init2():void
            {
                ncl = new NetStream( nc );  // used to send video on the server
                ncr = new NetStream( nc );
                video = new Video( 640, 480 );

                customClient = new Object();
                ncr.client = customClient;
                customClient.onBWDoneHandler;
                trace("connected");

                bandwidth= bandwidth_slider.value;
                framerate = sld_framerate.value;
                picture = sld_pic.value;
                keyframe = sld_keyframe.value;

                label1.text = bandwidth.toString();
                lbl_framerate.text = framerate.toString();
                lbl_pic.text = picture.toString();

                lbl_encoder.text = String(textLabel);


                    camera = Camera.getCamera("0".toString());
                    // 2k bytes (or ~16kbps) of bandwidth
                //  camera.setQuality( 65536 / 8, 80 );
                //  camera.setMode( 320, 240, 5, false );
                    // Set loopback as compressed
                    //camera.setLoopback( true );           
                    //video.attachCamera( camera );
                    camera.setMode(320,240,framerate, false );  // (height, width, frame rate)
                    //camera.setQuality( 62500, 0 );       // Ensure that no more than 62500 (?K/second) is used to send video
                    camera.setQuality( bandwidth, picture );

                    // with a minimum quality of 0
                    //camera.setMotionLevel(10,500);
                    camera.setKeyFrameInterval(keyframe);  // interpolation

                    h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_2);
                    //ncl.bufferTime = 0.3;
                    ncl.videoStreamSettings = h264Settings;

                    /*this.mic = Microphone.getEnhancedMicrophone();
                    if (!this.mic){
                        this.mic = Microphone.getMicrophone(-1);
                    };
                    this.mic.codec = SoundCodec.SPEEX;
                    this.mic.framesPerPacket = 1;
                    this.mic.setSilenceLevel(0, 2000);
                    this.mic.encodeQuality = 10;
                    this.mic.setLoopBack(true);

                    if (this.mic){
                        this.mic.setUseEchoSuppression(true);
                        //this.mic.rate = 22;
                        if (this.mic.gain != 60){
                            this.mic.gain = 60;
                        };
                    };
                    */


                    ncl.attachCamera( camera ); //Specifies a video stream from a camera to be displayed within the boundaries of the Video object in the application.
                    //ncl.attachAudio(this.mic);
                    microphone = Microphone.getMicrophone();
                    ncl.attachAudio( microphone );
                    ncl.publish("my1"); 

                    video.attachNetStream( ncr );   //Specifies a video stream to be displayed within the boundaries of the Video object in the application.
                    //ncr.bufferTime = 0.3;
                    ncr.play( "my1" );                  

                videoDisplay.video = video;
            }

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

            public function showHideCanvas():void{
                if(canvas.visible == false){
                    canvas.visible = true;
                }
                else{
                    canvas.visible = false;
                }
            }

            private function hideCanvas():void{
                canvas.visible = false;
            }

            private var myMenu:Menu;

            private function popUpEncoder():void{

                myMenu = new Menu();
                var dp:Object = [
                    {label: "H.264"},
                    {label: "Sorenson Spark"},
                    {label: "On2 VP6"}
                ];
                myMenu.dataProvider = dp;
                myMenu.addEventListener("itemClick", changeHandler);
                popup.popUp = myMenu;

            }

            private var textLabel:String;

            private function changeHandler(event:MenuEvent):void{
                textLabel = event.label;
                popup.label = textLabel;
                popup.close();
            }


        ]]>
    </mx:Script>

    <VideoContainer id="videoDisplay" x="-2" y="0" width="640" height="480" click="hideCanvas()"/>
    <s:Image id="img" x="0" y="0" width="24" height="24" click="showHideCanvas()" smooth="true"
             source="@Embed('../images/Settings-icon.png')"/>
    <mx:Canvas id="canvas" visible="false" x="0" y="34" width="208" height="267" backgroundAlpha="0.5"
               backgroundColor="#646464" borderAlpha="0.0" borderColor="#FFFFFF"
               borderVisible="false" color="#FFFFFF" cornerRadius="10">
        <mx:HSlider id="bandwidth_slider" x="79" y="5" width="75" maximum="70000"
                    minimum="0" snapInterval="500"/>
        <mx:Label id="label1" x="158" y="13" height="13" fontSize="8"/>
        <mx:Label x="12" y="9" color="#FFFFFF" fontFamily="Verdana" fontStyle="normal"
                  fontWeight="bold" text="Bandwith" textDecoration="none"/>
        <mx:HSlider id="sld_framerate" x="79" y="21" width="75" maximum="50"
                    minimum="0" snapInterval="1" value="15"/>
        <mx:Label id="lbl_framerate" x="158" y="29" height="15" fontSize="9"/>
        <mx:Label x="0" y="25" color="#FFFFFF" fontFamily="Verdana" fontWeight="bold"
                  text="Frame Rate"/>
        <mx:HSlider id="sld_pic" x="80" y="39" width="75" maximum="100" minimum="0"
                    snapInterval="1"/>
        <mx:Label id="lbl_pic" x="158" y="48" width="19" height="13" fontSize="9"/>
        <mx:Label x="29" y="44" width="67" color="#FFFFFF" fontFamily="Verdana" fontWeight="bold"
                  text="Picture"/>
        <mx:HSlider id="sld_keyframe" x="80" y="56" width="75" maximum="50"
                    value="5" minimum="0" snapInterval="1"/>
        <mx:Label x="4" y="61" fontFamily="Verdana" fontWeight="bold" text="Key Frame"/>
        <mx:Button x="69" y="141" label="Apply" chromeColor="#28A50F" click="init2();"
                   color="#FFFFFF" cornerRadius="0" fontFamily="Verdana" fontSize="10"
                   fontStyle="normal" fontWeight="bold"/>
        <mx:PopUpButton id="popup" x="52" y="85" label="Encoder" color="#0A0909"/>
        <mx:Label id="lbl_encoder" x="52" y="114" width="88" creationComplete="popUpEncoder()"/>
    </mx:Canvas>


</mx:WindowedApplication>

Aucun commentaire:

Enregistrer un commentaire