Reputation: 125
Thank you for taking the time to read my question! So I have a function in my code that gets called after a TimerEvent. Like this:
shootTimer.addEventListener(TimerEvent.TIMER, shoot, false, 0, true);
private function shoot(e:Event):void
there is no problem with that, but what if I want to call the function shoot for something else too. like let's say
if(speed > 5)
shoot();
it doesn't work like that, can someone please explain me how to do it? Thank you a lot, in advance.
Upvotes: 0
Views: 88
Reputation: 2473
You could do something like this
shootTimer.addEventListener(TimerEvent.TIMER, shoot, false, 0, true);
private function shoot(e:Event):void
{
realShoot();
}
if(speed > 5)
{
realShoot();
}
Upvotes: 0
Reputation: 6751
You can set a default for the parameter, so you can call it without an event :
private function shoot(e:Event = null):void
Upvotes: 3