setInterval.

  • shendel101
  • Born
  • Born
  • No Avatar
  • Joined: Aug 23, 2007
  • Posts: 2
  • Status: Offline

Post August 30th, 2007, 1:05 am

how to call setInterval to loop again after the clearInterval? example.. if i press button i want to call the loop again do its function. Thanks..
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 30th, 2007, 1:05 am

  • dhonsvick
  • Beginner
  • Beginner
  • No Avatar
  • Joined: May 27, 2007
  • Posts: 49
  • Status: Offline

Post August 30th, 2007, 9:01 pm

here is how I do it

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. }


Now you can start Interval with - startInterval()

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 45 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.