简体   繁体   中英

FLex MouseEvent doesn't fire when Mouse stays over element

i'm trying to make a scrollable box, when a mouse enters and STAYS on "wrapper"'s area, "pubsBox" moves 10 pixels to the left.

<mx:Canvas id="wrapper" height="80" width="750">
    <mx:HBox id="pubsBox" horizontalGap="10" height="80" width="100%" />
</mx:Canvas>

My problem is that I'm not sure how to make the MouseEvent.MOUSE_OVER work, to recognize that the mouse is still ON the area and so pubsBox should continue to move 10 pixels to the left every second.

I understand that i have to use a Timer, but what I'm concerned about is the fact that I can't get Flex to recognize that the mouse is still OVER "wrapper" and continue firing the event. Any ideas?

Use MouseEvent.MOUSE_OUT. Assume that the mouse is still over the wrapper until the mouse out event is fired. So essentially you will setup some sort of loop that will continually move the pubsBox until the MouseEvent.MOUSE_OUT event is fired.

<mx:Canvas id="wrapper" height="80" width="750" mouseOver="startMove(e)" mouseOut="stopMove(e)"> <mx:HBox id="pubsBox" horizontalGap="10" height="80" width="100%" /> </mx:Canvas>

In the startMove function, setup you timer etc, for the logic to achieve the move. In the stopMove function, add your logic to stop the timer and kill the move process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM