Stopwatch App is for Android. I am using Titanium Studio and JavaScript. I am trying to make my "Start" button perform another action. I want it to resume the time (after it has been stopped). I am also trying to make my "Lap" button work. The event listener does fire, but I want it to perform another action. Everything else works fine. I know this is very basic code and is probably an easy fix, but we all have our weak points."Button01" is the START button, and "Button04" is the LAP button. Any help will be appreciated. I have attached parts of my code below that is relevant to my question. Thanks.
var _startStopwatch = function() { timerlabel.value = '00:00:00.0'; var startTime = new Date(); intervalid = setInterval(_updateTimer, 1000); button03.title = 'STOP'; }; var _stopStopwatch = function() { clearInterval(intervalid); }; var started = false; var intervalid = null; var resume = true; //START BUTTON button01.addEventListener("click", function(e){ if (!started) { _startStopwatch(); started = true; } }); //RESET BUTTON button02.addEventListener("click", function(e){ if (started) { _stopStopwatch(); started = false; } timerlabel.text = '00:00:00.0'; }); //STOP BUTTON button03.addEventListener("click", function(e){ if (started) { _stopStopwatch(); started = false; } }); //LAP BUTTON NOT FUNCTIONING. button04.addEventListener("click", function(e) { if (button01 == null | button03 == null) { return 'Undefined'; } else { return(button03 - button01) / 1000; } });
2 Answers
Before anybody wastes any more time with this poster, please look at this thread.
In the previous thread, he wanted the Start button to only start the timer. I helped him do that.
Now he wants it to start the timer or resume it. There's no evidence he even tried to do anything to make that happen. He changed his mind about what he wants it to do, so he posted here to try to get somebody to write it for him.
This is really frustrating, and I suppose it's one of the downfalls of Titanium - somebody is marketing this as "mobile app development for beginners". Too many people in Q&A are here with absolutely no programming foundation whatsoever.
Titanium Mobile is:
easy to use for quick-and-dirty iOS applications
hard to use really well and cross platform
impossible to use for non-programmers
If you can't program your way out of a paper bag, please first learn how to program, then come take a crack at Titanium Mobile.
Hi Bruce,
can you explain a little bit more here, what is this kind of code...
else { return(button03 - button01) / 1000; }in button04 eventlistener...
Your Answer
Think you can help? Login to answer this question!