all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

Triggerring setInterval and Clear Interval with rollOvers


Triggerring setInterval and Clear Interval with rollOvers MikOne
4/16/2005 12:00:00 AM
flash actionscript: I am trying to trigger a function to begin executing after I roll over one_btn
and stop executing when I roll over btn_two or alternatively roll off button
one. If I omit the one_btn.onRollOver line and let the interval begin at the
time when the frame is read then the clearInterval function works when I roll
over two_btn...otherwise nada. If someone could help me I would be forever
grateful.

function randomImage () {
trace ("work darndit!")
}
one_btn.onRollOver= function() {
var intel = setInterval(randomImage, 1000);
}
two_btn.onRollOver = function() {
clearInterval(intel);
}
stop();

Thanks.
Re: Triggerring setInterval and Clear Interval with rollOvers lumeeguvnor
4/16/2005 12:00:00 AM
Re: Triggerring setInterval and Clear Interval with rollOvers MikOne
4/16/2005 12:00:00 AM
thanks for the advice.....it almost worked.....but only when I included an
extra line following the two_btn.onRollOver function (see below)....otherwise
setInterval just kept on chugging. And, of course, with my little addition
one_btn doesn't work any more.

function randomImage () {
trace ("work darndit!")
}
one_btn.onRollOver= function() {
var intel = setInterval(randomImage, 1000);
}
two_btn.onRollOver = function() {
one_btn.onRollOver = false;
clearInterval(intel);
}
stop();



Re: Triggerring setInterval and Clear Interval with rollOvers MikOne
4/16/2005 12:00:00 AM
My bad...I had removed the "var" in my longer working script but forgot to
exclude it when I cut and pasted from the last post.
Anywho, I managed to get it to work when rolling on and off a single button
but still had problems getting it to work properly when two buttons were
involved.
thanks you very much for helping and if you can think of why the two button
issue may have been problematic, please let me know.
Thanks again.


Re: Triggerring setInterval and Clear Interval with rollOvers lumeeguvnor
4/16/2005 12:00:00 AM
this works for me - assuming that you want the trace to start with
one_btn.onRollOver= function() {.............. }and end with
two_btn.onRollOver = function() {....................}

function randomImage () {
trace ("work darndit!")
}
one_btn.onRollOver= function() {
intel = setInterval(randomImage, 1000);
}
two_btn.onRollOver = function() {
clearInterval(intel);
}
stop();
Re: Triggerring setInterval and Clear Interval with rollOvers Byron Canfield
4/16/2005 11:03:14 AM
You still have the "var" in there, which makes the variable "intel", which
holds the id value of the setInterval, local to the function and cease to
exist upon conclusion of the one_btn.onRollOver function execution, making
it no longer available for clearInterval. Get the "var" out of there. The
setInterval, itself, is NOT local to the function, and will thus keep on
running until the Flash player session is terminated.

--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com


[quoted text, click to view]

AddThis Social Bookmark Button