views:

118

answers:

1

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

A: 

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.

Ryan M
Hi Ryan, can you elaborate?
Tomaszewski
Hopefully that helps, let me know if it still is not clear.
Ryan M
oh wait... i think i may know what you are saying. You are saying to start timer on mouseOver and only stop it if mouseOut.
Tomaszewski
Yes, that is correct. But you want to make sure that you keep resetting and starting the timer once it reaches 0 to keep moving the object, since the mouse it still hovering over the object. The timer will keep being reset and started until the mouseOut event is fired.
Ryan M