flex自定义ToolTip

本文展示了一个使用Flex实现自定义ToolTip的示例代码。通过创建一个实现了IToolTip接口的Panel组件,当鼠标悬停在指定按钮上时,会显示带有特定标题和内容的ToolTip。示例中包括了创建自定义提示所需的所有必要步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

flex自定义ToolTip
Tooltip代码

1. 其实也是官方例子
2. <?xml version="1.0"?>
3. <!-- tooltips/ToolTipComponents/PanelToolTip.mxml (tos.mxml)-->
4. <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
5. implements="mx.core.IToolTip"
6. width="200"
7. alpha=".8"
8. borderThickness="2"
9. backgroundColor="0xCCCCCC"
10. dropShadowEnabled="true"
11. borderColor="black"
12. borderStyle="solid"
13. title="feh"
14. >
15. <mx:Script><![CDATA[
16. import mx.controls.*;
17. [Bindable]
18. public var bodyText:String = "";
53. // Implement required methods of the IToolTip interface; these
54. // methods are not used in this example, though.
55. public var _text:String;
56.
57. public function get text():String {
58. return _text;
59. }
60. public function set text(value:String):void {
61. this._text=value;
62. Alert.show("toolTip");
63.
64. }
65. ]]></mx:Script>
66. <mx:Button label="test"/>
67. <mx:Text text="{bodyText}" percentWidth="100"/>
68.
69. </mx:Panel>
19. <?xml version="1.0"?>
20. <!-- tooltips/MainCustomApp.mxml -->
21. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
22. <mx:Script><![CDATA[
23. //import ToolTipComponents.PanelToolTip;
24. import mx.events.ToolTipEvent;
25.
26. private function createCustomTip(title:String, body:String, event:ToolTipEvent):void {
27. var ptt:tos= new tos();
28. ptt.title = title;
29. ptt.bodyText = body;
30. event.toolTip = ptt;
31. }
32. ]]></mx:Script>
33.
34. <mx:Button id="b1"
35. label="Delete"
36. toolTip=" "
37. toolTipCreate="createCustomTip('DELETE','Click this button to delete the report.', event)"
38. />
39.
40. <mx:Button id="b2"
41. label="Generate"
42. toolTip=" "
43. toolTipCreate="createCustomTip('GENERATE','Click this button to generate the report.', event)"
44. />
45.
46. <mx:Button id="b3"
47. label="Stop"
48. toolTip="Click this button to stop the creation of the report. This button uses a standard ToolTip style."
49. />
50.
51. </mx:Application>
52.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值