See SWF file here: Pacman

I’m having trouble locating this bug. When the board is complete, the main timeline is supposed to gotoAndPlay another scene. I have the first frame of the scene labeled “Board Done”. This frame also has AS that removes the dynamically created MovieClips. For debugging, I commented out the part that removes the main board container.

Actionscript Code:
//BoardContainer.removeMovieClip();
for(x=0;x<lives;x++)
    this["life"+x].removeMovieClip();
for(x=0;x<12;x++)
    this["round"+x].removeMovieClip();
FrameBorder.removeMovieClip();
Frameback.removeMovieClip();
Scores.removeMovieClip();

I don’t know why this would be a problem, but at this point, it was stopping, as though I had used gotoAndStop.


The board is supposed to end when the last dot is gotten. The checkForDot function does this, and it is called by the Player.onEnterFrame function. When checkForDot finds that there are no more dots, it is supposed to remove the Player.onEnterFrame function, since the player should no longer have control, and move the main timeline to the other scene:


Actionscript Code:
_global.checkForDot=function(x:Number,y:Number):Void
{
    //round pixel coordinates of player to find tile coordinate of dot
    x=Math.floor((x+7.5)/15);
    y=Math.floor((y+7.5)/15);

    if(map[x][y].Dot._currentframe==undefined)//no dot here
        return;
       
    if(map[x][y].Dot._currentframe==2)
        changeEnemies();
    else
        getDot.start(); //dot sound only
   
    map[x][y].Dot.removeMovieClip();
    numDots--;
    score++;
    checkScore(); //for extra life

    if(numDots==0) //no dots left - end round
    {
        round++;
        delete Player.onEnterFrame;
        _level0.gotoAndPlay("Board Done");
        //setTimeout(gotoAndPlay,100,"Board Done");
    }
}

By not removing the board container MovieClip, I found that the main timeline was not moving. It must be some other timeline since the code on that frame is executed, but the code running from the main timeline during the game is still running. If it weren’t, new bonuses would not appear and the pause function would not work.

As you can see, I tried specifying _level0 for the gotoAndPlay, I tried making the function global, and I tried using setTimeout. When I use setTimeout, the code on the other scene never executes.

Does anyone have any hint of an idea why this happens?