Search code examples
actionscript-3functionflashscene

Flash AS3: How can I get functions to exit the game loop?


I am working on a Flash project with multiple scenes. I use the function:

function gameloop(e:Event)  {

to add my functions in to one scene, but when switching the scene I am rained on with errors because the objects used in the other scene are no longer on screen. Is there an opposite to the code I pasted here to take functions out of the game loop for my other scenes?


Solution

  • function gameloop(e:Event)  {
        if(currentFrame != 2){
            return;
        }
    }
    

    Check currentFrame in the loop.