I've got the below function which acts as a timer in my code:
var countDown = function( m , s, fn_tick, fn_end ) { return { total_sec:m*60+s, timer:this.timer, set: function(m,s) { this.total_sec = parseInt(m)*60+parseInt(s); this.time = {m:m,s:s}; return this; }, start: function() { var self = this; this.timer = setInterval( function() { if (self.total_sec) { self.total_sec--; fn_tick(); } else { self.stop(); fn_end(); } }, 1000 ); return this; }, stop: function() { clearInterval(this.timer); this.time = {m:0,s:0}; this.total_sec = 0; return this; } }; };However i get the below error when it runs for the first time:
In ti:/bootstrap.js:131,32 Message: Uncaught Error: Invalid value, expected type Number. Source: return Titanium.clearTimeout.apply(Titanium, arguments);I found a ticket that is open about this issue https://jira.appcelerator.org/browse/TIMOB-14213 which suggessts that i need to nullify the setInterval variable before running however if I do
this.timer = null
it makes no difference
Running on Android with latest SDK on Alloy