Actionscript 3 压力机和长压力机
好吧,我读了很多关于这个的帖子,但是我找不到足够好的答案。 我的构造函数类中有这样一个:Actionscript 3 压力机和长压力机,actionscript-3,Actionscript 3,好吧,我读了很多关于这个的帖子,但是我找不到足够好的答案。 我的构造函数类中有这样一个: this.addEventListener(MouseEvent.MOUSE_DOWN, mousedown); this.addEventListener(MouseEvent.MOUSE_UP, mouseup) myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, showInfo); 我有三个功能: private function mou
this.addEventListener(MouseEvent.MOUSE_DOWN, mousedown);
this.addEventListener(MouseEvent.MOUSE_UP, mouseup)
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, showInfo);
我有三个功能:
private function mouseup(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseup);
myTimer.reset();
}
private function showInfo(event:MouseEvent):void{
//long press code
}
private function mousedown(event:MouseEvent):void{
myTimer.start();
}
在通常的点击中,它会执行它应该执行的操作,但在长点击(1.5秒)时,它会重复此错误:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::TimerEvent@2ff0bab1 to flash.events.MouseEvent.
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/tick()
另一件事..正常点击时应该有一个动作,长点击时应该有另一个动作。
我的代码在长时间单击时执行这两个操作。有什么建议可以让它不在长媒体上运行第一个动作吗?
谢谢。事件类型应为TimerEvent,而不是MouseeEvent
private function showInfo(event:TimerEvent):void{
//long press code
}
谢谢,这解决了我的错误问题,现在剩下的就是如何禁用长按时的第一个操作:解决了,很抱歉打扰您。:)@如果Pan正确回答了您的问题,您应该将其标记为正确,以结束问题并奖励Pan声誉(选择左侧向下箭头下的概述复选标记)