1
votes

I am trying to achieve a continuous mouseDown event when I press a button, I have set the autoRepeat attribute of the button to true, and I have created both mouseUp and mouseDown event handlers, but when I press and hold in the button, it doesn't continue firing, it just fires once, I am new to Flash Builder, so I am not sure if I am missing anything, here is my code,

<?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>

I am not sure why this is not working, I just need it to keep firing when the button is in the down state.

Thanks in advance!

1

1 Answers

1
votes

Instead of mouseEvent i believe you should use ComponentEvent.BUTTON_DOWN