Simple Torch
//Called when application is started. function OnStart() { //Create a layout lay = app.CreateLayout( "linear", "VCenter,FillXY" ); lay.SetBackColor("#ff999999") //Create Camera view cam = app.CreateCameraView( .003,.003 ); cam.SetOnReady( capture ) lay.AddChild( cam ) //Create a text label and add it to layout. txt = app.CreateText( "Torch" ); txt.SetTextColor("#ff000000") txt.SetTextSize( 32 ); lay.AddChild( txt ); //Create 'Use Flash' check box. chkFlash = app.CreateCheckBox( "Off" ); chkFlash.SetMargins( 0,0.1,0,0 ); chkFlash.SetOnTouch( chkFlash_OnTouch ); lay.AddChild( chkFlash ); //Add layout to app. app.AddLayout( lay ); } //Start Preview function capture() { cam.StartPreview(); } //Handle 'Use Flash' checkbox touch function chkFlash_OnTouch(value) { cam.SetFlash(value); if(value==true) chkFlash.SetText("On"); else chkFlash.SetText("Off"); }