K
K
Kusmich2015-10-15 20:35:44
JavaScript
Kusmich, 2015-10-15 20:35:44

How to make each flip function run in half a second?

How to implement alternate launch of flip functions every 0.5 sec?

var cur = 1
     
     if(cur > 0  ){
      
      h = 2
      flip('hoursUp1', 'hoursDown1', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 3
      flip('hoursUp2', 'hoursDown2', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 4
      flip('hoursUp3', 'hoursDown3', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 5
      flip('hoursUp4', 'hoursDown4', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 6
      flip('hoursUp5', 'hoursDown5', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 7
      flip('hoursUp6', 'hoursDown6', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 8
      flip('hoursUp7', 'hoursDown7', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 9
      flip('hoursUp8', 'hoursDown8', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      h = 10
      flip('hoursUp9', 'hoursDown9', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
    
      flip('hoursUp10', 'hoursDown10', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      
      flip('hoursUp11', 'hoursDown11', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      flip('hoursUp12', 'hoursDown12', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      flip('hoursUp13', 'hoursDown13', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      flip('hoursUp14', 'hoursDown14', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      flip('hoursUp15', 'hoursDown15', h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');

      h_current = h;
    
    
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
titronfan, 2015-10-15
@Kusmich

More or less like this:

var count = 0;
  var interval = 500;
  var refresh = function() {
      count++;
      flip('hoursUp'+count, 'hoursDown'+count, h, 'Single/Up/'+2+'/', 'Single/Down/'+1+'/');
      setTimeout(function() {
          refresh();
      }, interval);
  };
  refresh();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question