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!
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".
This should do it.
private var isBossTime:Boolean = false;
private function addBoss():void
{
if(kills >= 3 && isBossTime == false)
{
trace("boss time");
isBossTime = true;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With