Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Carlos www.abismo.com.br

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Finding stuff in strings / or not!

Contains is an actionscript function that I use a lot. From Kirupa

contains = function (input, arrayData) {
  for (i=0; i<arrayData.length; i++) {
    if (arrayData[i] == input) {
      return 1;
    }
  }
  return -1;
};

Random Numer

Random number function - returns a number between min and max
Receives (min, max)
Returns randomNum


function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}

Actionscript

// Countdown code

countDown = function() {
        seconds_conta = seconds_conta - 1;
        hours = int(seconds_conta / 3600);
        minutes = int((seconds_conta / 60) - (hours * 60));
        //seconds = int(seconds_conta-((hours*3600)+minutes*60));
        seconds = int((seconds_conta % 60));
        
        //Se for menor que dez, acrescenta um zero
        if(minutes<10){
                minutes="0"+minutes;
        }
        if(seconds<10){
                seconds="0"+seconds;
        }
        
        //Será que precisa colocar no frame correto?
        timer_txt.text=(hours+":"+minutes+":"+seconds);
        
                //trace("seconds_conta: "+seconds_conta);
                //trace("hours: "+hours);
                //trace("minutes: "+minutes);
                //trace("seconds: "+seconds);
        
        if (seconds_conta == 0) {
          clearInterval(timer);
                  //Chama função de acabar a contagem!
                  //fim_das_questões();
     }
} 

///////// Acrescentar no código
//Tempo total inicial em segundos ->Calculado a partir da quantidade de questões
seconds_conta = 185;
///////// Inicia o timer
//A cada 1000 ms, ativa a função countDown, diminuindo um segundo do total
timer = setInterval(countDown, 1000);

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed