感谢您抽出时间阅读我的问题!所以我的代码中有一个在TimerEvent之后调用的函数。如下所示:
shootTimer.addEventListener(TimerEvent.TIMER, shoot, false, 0, true);
private function shoot(e:Event):void这是没有问题的,但如果我也想为其他东西调用函数shoot怎么办?比方说
if(speed > 5)
shoot();它不是那样工作的,有人能给我解释一下怎么做吗?非常感谢,提前说出来。
发布于 2013-01-08 07:05:03
您可以为参数设置默认值,这样就可以在没有事件的情况下调用它:
private function shoot(e:Event = null):void发布于 2013-01-08 07:06:46
你可以这样做
shootTimer.addEventListener(TimerEvent.TIMER, shoot, false, 0, true);
private function shoot(e:Event):void
{
realShoot();
}
if(speed > 5)
{
realShoot();
}https://stackoverflow.com/questions/14205568
复制相似问题