<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:cam="com.polygeek.vid.*" viewSourceURL="srcview/index.html">
    
    <!--
    NOTE: 
    FlexBuilder now displays the live feed from your webcam when you switch to
    Design view. Which is sort of cool and all but when you switch back to 
    Source view it doesn't let go of the camera. So when you publish/test the 
    application you won't be able to see anything - or record - because FlexBuilder
    already has the stream and there can be only one.
    
    You'll have to restart FlexBuilder to get it to give up the connection to your webcam. 
    
    -->
    <cam:WebCamViewerMXML id="recorder" x="10" y="10" />
        
    <mx:Button id="recordToggle" click="onRecord( event );" label="Start Recording"  x="106" y="278"/>
    
    <mx:Script>
        <![CDATA[
            
            private function onRecord( e:Event ):void {
                if( recordToggle.label == "Start Recording" ) {
                    recorder.recordStream( true );
                    recordToggle.label = "Stop Recording";
                } else {
                    recorder.recordStream( false );
                    recordToggle.label = "Start Recording";                    
                }
            }
            
        ]]>
    </mx:Script>
    
</mx:Application>