This may be a shot in the dark but does anyone know if you can run a For loop within an interval? I am running the below code and for whatever reason when I run “barPosDwn()” without the interval (press and release the button) the For loop runs just fine. However when I run “barPosDwn()” from and interval (press and hold the button) the trace on the For loop comes back undefined.
Does anyone have any ideas? Any help would be greatly appreciated.
PHP Code:
sDSS_btn.onPress = function(){
barPosDwn();
var barPosDwnTime:Number = getTimer()/1000;
barPosDwnTimerFun(barPosDwnTime);
}
sDSS_btn.onRelease = function(){
delete this.onEnterFrame;
clearInterval(barPosDwnInt);
}
function barPosDwnTimerFun(barPosDwnTime) {
this.onEnterFrame = function() {
if ((getTimer()/1000)-barPosDwnTime>.25) {
barPosDwnInt = setInterval(barPosDwn, _root.intervalSpeed);
delete this.onEnterFrame;
}
};
}
function barPosDwn() {
optionBar = int((setOpBar._y)*10)/10;
if (ok == true) {
if (optionBar>=151.9 && optionBar<=281.9) {
ok = false;
endP = optionBar+26;
motionT = new Tween(setOpBar, "_y", Regular.easeInOut, optionBar, endP, .4, true);
//this prevents the bar from going out of sequence
motionT.onMotionFinished = function() {
ok = true;
};
} else if (optionBar == 307.9 && set11._y != 311.8) {//This controls the MC movement
ok = false;
for (i=1; i<12; i++) {
this["set"+i]._y -= 26;
trace(this["set"+i]._y);
}
ok = true;
}
}
}