简体   繁体   English

当鼠标停留在元素上时,不会触发FLex MouseEvent

[英]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. 我正在尝试制作一个可滚动的框,当鼠标进入并且在“包装器”区域停留时,“ pubsBox”向左移动10个像素。

<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. 我的问题是我不确定如何使MouseEvent.MOUSE_OVER工作,以识别鼠标仍在该区域上,因此pubsBox应该继续每秒向左移动10个像素。

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. 我知道我必须使用Timer,但是我担心的是我无法让Flex意识到鼠标仍然在“包装器”上并继续触发该事件。 Any ideas? 有任何想法吗?

Use MouseEvent.MOUSE_OUT. 使用MouseEvent.MOUSE_OUT。 Assume that the mouse is still over the wrapper until the mouse out event is fired. 假定鼠标仍然在包装上,直到触发了mouse out事件为止。 So essentially you will setup some sort of loop that will continually move the pubsBox until the MouseEvent.MOUSE_OUT event is fired. 因此,从本质上讲,您将设置某种循环,该循环将连续移动pubsBox,直到触发MouseEvent.MOUSE_OUT事件为止。

<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. 在startMove函数中,设置计时器等,以实现移动的逻辑。 In the stopMove function, add your logic to stop the timer and kill the move process. 在stopMove函数中,添加逻辑以停止计时器并终止移动过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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