setInterval.

  • shendel101
  • Born
  • Born
  • No Avatar
  • Inscription: Aoû 23, 2007
  • Messages: 2
  • Status: Offline

Message Août 30th, 2007, 1:05 am

comment appeler setInterval boucle à nouveau après l'clearInterval? par exemple .. si je presse le bouton i à appeler de nouveau faire la boucle de sa fonction. Merci ..
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Août 30th, 2007, 1:05 am

  • dhonsvick
  • Beginner
  • Beginner
  • No Avatar
  • Inscription: Mai 27, 2007
  • Messages: 49
  • Status: Offline

Message Août 30th, 2007, 9:01 pm

Voici comment je fais

Code: [ Select ]

var myInt;
startInterval();
var who:Array = new Array("He","She","I","ME");

function startInterval(){
  clearInterval(myInt); // clear the interval, to make sure you dont over lap...which has interesting results ;)
  myInt = setInterval(this, "myFunction", 1000);
}

function stopInt(){
  clearInterval(myInt);
}



function myFunction(){
    var randomNum:Number = Math.floor(Math.random() * (3 - 0 + 1)) + 0;
 trace( who[randomNum]+" likes to Move it , Move it");
}
  1. var myInt;
  2. startInterval();
  3. var who:Array = new Array("He","She","I","ME");
  4. function startInterval(){
  5.   clearInterval(myInt); // clear the interval, to make sure you dont over lap...which has interesting results ;)
  6.   myInt = setInterval(this, "myFunction", 1000);
  7. }
  8. function stopInt(){
  9.   clearInterval(myInt);
  10. }
  11. function myFunction(){
  12.     var randomNum:Number = Math.floor(Math.random() * (3 - 0 + 1)) + 0;
  13.  trace( who[randomNum]+" likes to Move it , Move it");
  14. }


Maintenant vous pouvez démarrer avec Interval - startInterval ()

Afficher de l'information

  • Total des messages de ce sujet: 2 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 39 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC