

function onPress() { //scroll immediately scrollDown(); //setup pause _scrollID = setInterval(this,"initDownScroll",350); } function initDownScroll() { clearInterval(_scrollID); //scroll immediately again scrollDown(); //setup continuous scrolling _scrollID = setInterval(this,"scrollDown",50); } function scrollDown() { //handle scrolling here }Thankfully there is a easy fix that lets you only have to use one function for both intervals:
function onPress() { //scroll immediately scrollDown(); //setup pause _scrollID = setInterval(this,"scrollDOwn",350,true); } function scrollDown(first:Boolean) { if(first) { clearInterval(_scrollID); //setup continuous scrolling _scrollID = setInterval(this,"scrollDown",50); } //handle scrolling here }So just by passing an extra parameter to the first interval, the scrollDown function can detect that the pause is over and setup the next interval.
if(true || complexFunction()) ... if(false && complexFunction()) ...In both examples complexFunction() will never be executed since it is unnecessary to evaluate the expression. So if your looking for that extra bit of performance, it's always good practice when forming potentially intensive logical comparisons, to put the least complicated comparisons first.
This site is licensed under a
Creative Commons License