是否曾经奇怪如何才能控制toolTip的显示时间?不用再觉得惊奇了,通过设置ToolTipManager.hideDelay
属性,你可以控制toolTip的显示默认时间为10秒或者任何你想设置的时间。简单的设置一下这个值就可以了。
接下来的例子演示了如何通过设置ToolTipManager.hideDelay
属性,将ToolTip的显示有效时间设为2.5秒(默认为10秒或者是10000微秒)。
让我们先来看一下Demo(
可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download:
main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.managers.ToolTipManager;
- // milliseconds (default 10000)
- ToolTipManager.hideDelay = 2500;
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar dock="true">
- <mx:Label text="Mouse over the Button below to see the tool tip." />
- </mx:ApplicationControlBar>
- <mx:Button id="button" label="click me"
- toolTip="I'm a fabulous tool tip." />
- <mx:Label text="The tool tip will disappear after {(ToolTipManager.hideDelay/1000).toFixed(1)} seconds." />
- </mx:Application>