clearInterval stops an interval from executing, it doesn't remove the ID that was assigned to the interval.
>From the docs: <quote> setInterval: Returns Number - An integer that identifies the interval (the interval ID), which you can pass to clearInterval() to cancel the interval. </quote> Each time you call setInterval a numeric identifier is returned, which is auto incremented as you can see in your example. And this also explains why it is so important to clear an interval before creating a new one, which was mentioned a few times here recently. regards, Muzak ----- Original Message ----- From: "Helmut Granda" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Tuesday, April 24, 2007 11:18 PM Subject: [Flashcoders] Clear Set Interval Q: > Is there any specific reason why after calling clearInterval the variable > with the interval returns 1 instead of undefined/null? > > Following the docs and creating a simple item we get different results (no > different but no what our logic might expect) > > function callback() { > trace("interval called: "+getTimer()+" ms."); > } > > var intervalID:Number = setInterval(callback, 1000); > trace(intervalID); > > clear_btn.onRelease = function(){ > clearInterval( intervalID ); > trace(intervalID);//shouldnt this return undefined/null? > trace("cleared interval"); > }; > > start_btn.onRelease = function() { > intervalID = setInterval(callback, 1000);// this adds 1 to the current > interval > trace(intervalID); > } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com