how to make Stopwatch Timer

how to make Stopwatch Timer?



 This is very simple and easy steps to make an App on DroidScript
Coding is very very Easy. Very small area of coding to be used in this app
Note that the DroidScript version 2.50 used in this app.
Let's build your app in no time using ApkBuilder Plugins
First make your New App So, Click on the New buttion in the Top Screen. 

Stopwatch Timer:

var Tim=0;

var sec=0;

var min=0;

var hrs=0;



//Called when application is started.

function OnStart()

{

 //Create a layout with objects vertically centered.

 lay = app.CreateLayout( "Linear", "FillXY" )

 //Create a text label and add it to layout.

 txt = app.CreateText( "Stop Watch Timer" )

 txt.SetTextSize( 32 )

 lay.AddChild( txt )

  txtStatus = app.CreateText( "Status:"+status)

 txtStatus.SetTextSize( 16)

 lay.AddChild( txtStatus)

  //Header text

startBut = app.CreateButton( "Start",0.8 )

startBut.SetOnTouch( startBut_OnTouch )

startBut.SetBackColor("#33ff6e")

startBut.SetTextColor("#00000e")

lay.AddChild( startBut )

stopBut = app.CreateButton( "Stop",0.8 )

stopBut.SetOnTouch( stopBut_OnTouch )

stopBut.SetBackColor("#33ff6e")

stopBut.SetTextColor("#00000e")

lay.AddChild( stopBut )

 //Text Field for all Time values hrs,min,sec

  txtHead = app.CreateText( hrs+":"+min+":"+sec, 0.8 )

 txtHead.SetTextColor( "#3fff0e")

 txtHead.SetTextShadow( 1, 0,1, "#88ffffff" )

 txtHead.SetTextSize( 70)

 lay.AddChild( txtHead )

 //Text Field for all Timer stop value

 txtHead2= app.CreateText( "", 0.8 )

  txtHead2.SetTextColor( "#3fe03e")

 txtHead2.SetTextShadow( 1, 0,1, "#88ffffff" )

 txtHead2.SetTextSize( 70)

 lay.AddChild( txtHead2 )

 txtHead2.Gone();

 //Add layout to app. 

 app.AddLayout( lay )

}

function Time()

{



Tim++;

if (Tim<=60)

{ sec++;

txtHead.SetText( hrs+":"+min+":"+sec, 0.8)

}

if (sec>=60)

{

Tim=0;

sec=0;

min++;

txtHead.SetText( hrs+":"+min+":"+sec, 0.8)

}

 if (min>=60)

 {

 hrs++;

txtHead.SetText( hrs+":"+min+":"+sec, 0.8 )

 min=0;}

}

var status=0;

function startBut_OnTouch()

{

if (status<=0){

status=1;

  setInterval ("Time()",1000);

  }

  if (txtHead2.IsVisible()){

txtHead2.Gone();

 Tim=0;

sec=0;

hrs=0;

min=0;

txtHead.SetText( hrs+":"+min+":"+sec, 0.8 )

txtHead.Show();

txtStatus.SetText( "Status: "+"On")

}

}

function stopBut_OnTouch()

{

txtStatus.SetText( "Status: "+"Off")

txtHead.Gone();

txtHead2.Show();

 txtHead2.SetText( txtHead.GetText())

}

Post a Comment

0 Comments