User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

sample_code:torch

Simple Torch

Torch.js
//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");
   } 

Home»Sample Code

sample_code/torch.txt · Last modified: 2016/08/29 14:14 (external edit)