前几天在做公司的监控点地图项目的时候,老大们提了一个需求,就是在按住地图的导航按钮(类似于GoogleMap左上方的那五个按钮)时,地图会一直向某个方向移动直至按钮松开为止。查了一下MouseEvent类的事件,用MouseEvent.MOUSE_CLICK 与 MouseEvent.MOUSE_DOWN 这两个鼠标事件都无法实现。最后通过查API中的Button类,终于发现:
buttonDown: Event
Event Object Type:
FlexEvent.type property =
mx.events.FlexEvent
FlexEvent.type property =
mx.events.FlexEvent.BUTTON_DOWN
Dispatched when the user presses the Button control. If the autoRepeat
property is true
, this event is dispatched repeatedly as long as the button stays down.
The
FlexEvent.BUTTON_DOWN
constant defines the value of the
type
property of the event object for a
buttonDown
event.
意思是说,Button对象有个名为buttonDown的事件,该事件在每次用户按下Button是会被分派(即按钮发出该事件),如果按钮的autoRepeat属性值为true,用户按住按钮时按钮会一直发出该事件。
找到了这个东东,功能就自然而然实现了,呵呵~