<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" viewActivate="view1_viewActivateHandler(event)" title="{data.title}" xmlns:components="components.*" xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import spark.events.ViewNavigatorEvent;
import views.SnippetView;
protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
// TODO Auto-generated method stub
if (Camera.isSupported)
{
var v:Video = new Video(300, 200);
uic.addChild(v);
var c:Camera = Camera.getCamera();
c.setMode(300, 200, 10);
v.attachCamera(c);
}
else
{
li.text = "Camera not supported";
}
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if (CameraUI.isSupported)
{
var cameraUI:CameraUI = new CameraUI();
cameraUI.addEventListener(MediaEvent.COMPLETE, function(event:MediaEvent):void {
img.source = event.data.file.url;
});
cameraUI.launch(MediaType.IMAGE);
}
else
{
li.text = "CameraUI not supported";
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:navigationContent>
<s:Button label="Snippet" click="navigator.pushView(views.SnippetView,data)"/>
<s:Button label="Tutorial" click="navigateToURL(new URLRequest(data.tutorial))"/>
</s:navigationContent>
<s:VGroup paddingLeft="10" paddingTop="10">
<s:HGroup gap="10" width="{this.width}" >
<mx:UIComponent id="uic" width="300" height="200"/>
<s:Label text="This is using the Camera class."/>
</s:HGroup>
<s:HGroup gap="10" width="{this.width}" >
<s:Image id="img" width="300" height="200"/>
<s:Button label="Click here to use the native Camera app" click="button1_clickHandler(event)"/>
</s:HGroup>
</s:VGroup>
<s:Label id="li" text="" top="300" horizontalCenter="0" />
<components:QuestionBlock bottom="40" horizontalCenter="0" questionData="{data}"/>
</s:View>