Hi
Im having some issues with running two seperate setIntervals, they both seem to be conflicting each other.
on my first frame of my movie I have the following actionscript:
[COLOR=slategray]var stageWidth:Number = Stage.width;[/COLOR]
[COLOR=slategray]var stageHeight:Number = Stage.height;[/COLOR]
[COLOR=slategray]var timeCounter:Number = 0;[/COLOR]
[COLOR=slategray]var intervalID:Number;[/COLOR]
[COLOR=slategray]var hasMoved:Boolean;[/COLOR]
[COLOR=slategray]var oldX:Number = _root._xmouse;[/COLOR]
[COLOR=slategray]var oldY:Number = _root._ymouse;[/COLOR]
[COLOR=slategray]this.onEnterFrame = function(){[/COLOR]
[COLOR=slategray]var xPos:Number = _root._xmouse;[/COLOR]
[COLOR=slategray]var yPos:Number = _root._ymouse;[/COLOR]
[COLOR=slategray]if( Math.round( oldX ) != Math.round( _root._xmouse ) || Math.round( oldY ) != Math.round( _root._ymouse ) ){[/COLOR]
[COLOR=slategray]if( hasMoved == false ){[/COLOR]
[COLOR=slategray]//trace( “moved…stopping timer” );[/COLOR]
[COLOR=slategray]stopTimer();[/COLOR]
[COLOR=slategray]tweenAnimOut();[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]hasMoved = true;[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]else{[/COLOR]
[COLOR=slategray]if( hasMoved == true ){[/COLOR]
[COLOR=slategray]//trace( “stationary…starting timer” );[/COLOR]
[COLOR=slategray]startTimer();[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]hasMoved = false;[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]oldX = _root._xmouse;[/COLOR]
[COLOR=slategray]oldY = _root._ymouse;[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]function startTimer(){[/COLOR]
[COLOR=slategray]intervalID = setInterval( timedTweenAnimIn, 10000 );//10 seconds[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]function stopTimer(){[/COLOR]
[COLOR=slategray]timeCounter = 0;[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]function timedTweenAnimIn(){[/COLOR]
[COLOR=slategray]if( timeCounter == 1 ){[/COLOR]
[COLOR=slategray]tweenAnimIn();[/COLOR]
[COLOR=slategray]clearInterval( intervalID );[/COLOR]
[COLOR=slategray]//trace( “interval cleared” );[/COLOR]
[COLOR=slategray]stopTimer();[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]else{[/COLOR]
[COLOR=slategray]timeCounter++;[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]function tweenAnimIn(){[/COLOR]
[COLOR=slategray]regionSwitch_mc.gotoAndPlay(“start”)[/COLOR]
[COLOR=slategray]}[/COLOR]
[COLOR=slategray]function tweenAnimOut(){[/COLOR]
[COLOR=slategray]regionSwitch_mc.gotoAndPlay(“stop”)[/COLOR]
[COLOR=slategray]}[/COLOR]
Which basically triggers a movie to play when the mouse isn’t moving after a set amount of time (like a screensaver) and stops it when the mouse moves. BUT. within my triggered movie (regionSwitch_mc.) I have another piece of actionscript which is shuffling from one frame to another after an amount of time:
[COLOR=slategray]var intervalID:Number;[/COLOR]
[COLOR=slategray]intervalID = setInterval (triggerNext,4000);// 4 seconds[/COLOR]
[COLOR=slategray]function triggerNext(){[/COLOR]
[COLOR=slategray]gotoAndStop(2);[/COLOR]
[COLOR=slategray]clearInterval(intervalID);[/COLOR]
[COLOR=slategray]}[/COLOR]
What I am finding is that the first piece of code is working fine and the Interval is clearing correctly, however when the mouse moves, the interval is cleared and the triggered movie (regionSwitch_mc) is stopped the interval is continuing to run creating two events that change frames, the first being tweenAnimIn and the second being the small piece of code from within regionSwitch_mc.
It is also the case that every time I move the mouse another event is called which changes frames, stacking on top of the last.
My instincts tell me that both setIntervals need to be cleared when the mouse is moved but regionSwitch_mc.clearInterval(intervalID) doesn’t do the trick. Can anyone help?
Thanks in advance.