Forum Moderators: open

Message Too Old, No Replies

Actionscript help with setInterval

Basic counter functions with setInterval

         

jomoweb

7:14 pm on Jan 9, 2008 (gmt 0)

10+ Year Member



I am making an interactive map where the user mouses over a button and a longitude marker slides over while the degrees will count downwards (i.e. 119, 118, 117). Then, when the button is moused off, the marker slides back to the original position , and the counter counts down until the original value is met.

The counter is dynamic text (Var: longitude). Here is the code I have so far. The rollOver/countdown sequence seems to work perfectly, but the releaseOutside, rollOut / count upwards part is buggy and seems to put the counter in an infinite loop between 117 and 118...

I would immensely appreciate feedback on how to make this script work, and any tips you have to code this better. Thanks!

onClipEvent (load) {
_parent.longitude = 119;
}
on (rollOver) {
CountLong = function (reel) {
if (_parent.longitude>117) {
--_parent.longitude;
}
};
setInterval(CountLong, 700, "reel");
}
on (releaseOutside, rollOut) {
CountLong = function (reel) {
if (_parent.longitude<119) {
++_parent.longitude;
}
};
setInterval(CountLong, 700, "reel");
}

jomoweb

10:14 pm on Jan 9, 2008 (gmt 0)

10+ Year Member



Solution:

onClipEvent (load) {
_parent.longRight = 119;
}

on (rollOver) {
clearInterval(rLongScroll);
var rLongScroll = setInterval(Reel, 500);
function Reel() {
if (_parent.longRight>117) {
_parent.longRight--;
}
}
}

on (releaseOutside, rollOut) {
clearInterval(rLongScroll);
var rlongScroll = setInterval(Reel, 500);
function Reel() {
if (_parent.longRight<119) {
_parent.longRight++;
}
}
}