Hi guys, can any of you point out if this code is wrong or do I have a bug in my Flash? It’s sopposed to be a simple move function, called by an interval, and after reaching the border of the film, it’s sopposed to stop. pretty simple, right? right, but the &&%&^% thing won’t stop…
Here’s the code I’ve used: (mcBall = 1 framed movieClip)
_root.onEnterFrame = function()
{
function fMoveIt():Void
{
mcBall._x += 10;
trace(" function fMoveIt is called by setInterval, mcBall._x = " + mcBall._x);
if (mcBall._x >= (Stage.width - mcBall.width))
{
trace(“calling clearInterval() to stop the loop”);
clearInterval(mcBall.intervalID);
}
}
mcBall.intervalID = setInterval(fMoveIt, 50, mcBall);
};
Here’s the Output Window:
…
function fMoveIt is called by setInterval, mcBall._x = 246.7
calling clearInterval() to stop the loop
function fMoveIt is called by setInterval, mcBall._x = 256.7
calling clearInterval() to stop the loop
function fMoveIt is called by setInterval, mcBall._x = 266.7
…
…
…
function fMoveIt is called by setInterval, mcBall._x = 6106.7
calling clearInterval() to stop the loop
function fMoveIt is called by setInterval, mcBall._x = 6186.7
calling clearInterval() to stop the loop
function fMoveIt is called by setInterval, mcBall._x = 6196.7
calling clearInterval() to stop the loop
…
…
and so on … so is it me or is it a bug? (I really hope it’s me)
Any ideas??
I’ve also uploaded the file, just in case.
thanks in advance!