当我按下一个按钮时,我试图实现一个连续的mouseDown事件,我已经将按钮的autoRepeat属性设置为真,并且我已经创建了mouseUp和mouseDown事件处理程序,但是当我按住按钮时,它不会继续激发,它只激发一次,我是新接触Flash Builder的,所以我不确定我是否遗漏了什么,这是我的代码。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="621" height="382" minWidth="955" minHeight="600"
>
<fx:Script>
<![CDATA[
protected function bam_mouseDownHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
text_me.text += "Down...";
}
protected function bam_mouseUpHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
text_me.text += "UP!";
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextArea id="text_me" x="31" y="153" width="562" height="206" />
<s:Button id="bam" x="31" y="83" label="BAM" autoRepeat="true" mouseDown="bam_mouseDownHandler(event)" mouseUp="bam_mouseUpHandler(event)" />
</s:Application>我不确定为什么这不能工作,我只是需要它在按钮处于按下状态时继续触发。
提前感谢!
发布于 2011-11-16 20:20:18
我认为你应该使用ComponentEvent.BUTTON_DOWN而不是mouseEvent
https://stackoverflow.com/questions/8151393
复制相似问题