AS3 - How do I stop a function?
actionscript-3
Solution
private function addBoss():void{
if(kills >= 3){
trace("boss time");
removeBossEnterFrame();
}
}
private function removeBossEnterFrame():void{
removeEventListener(Event.ENTER_FRAME, addBoss);
}
I'd prob remove the Enterframe event listner thats calling the addBoss function once you trace out "boss time".
Problem
I have a function in my "enterFrameHandler* function and it is structured like this: ``` private function addBoss():void{ if(kills >= 3){ trace("boss time"); } } ``` Since "addBoss" is a part of my ENTER_FRAME event listener function, "boss time" is traced infinitely as soon as kills reaches 3. I would like this function to stop as soon as it activates 1 time. Is there another event listener I could use that will check for the function, but then stop as soon as it goes off? Any suggestions would be appreciated. Thanks!