Flex 4 tooltip实例

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
			   creationComplete="application1_creationCompleteHandler(event)">
	
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		<mx:Rotate id="rotate" />
		<mx:Fade id="fadeIn" alphaFrom="0" alphaTo="1" duration="2000"/> 		
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.events.ToolTipEvent;
						
			import spark.events.IndexChangeEvent;
			import mx.managers.ToolTipManager;
			
			import mx.core.UIComponent;
			
			import mx.managers.ToolTipManager;   
			import mx.controls.ToolTip;   
			public var myTip:ToolTip;   
			
						
			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{
				ToolTipManager.showEffect= fadeIn;//rotate;//fadeIn; //显示tooltip的特效 
				ToolTipManager.hideEffect=fadeIn;// rotate;//fadeIn; //隐藏 tooltip的特效 
				
				showMyTooltip(one, "第一步开始");				
			}
			
			private function showMyTooltip(displayObject:UIComponent, tip:String):void{
				var tipX:Number = displayObject.x + displayObject.width + 10;
				var tipY:Number = displayObject.y;
				myTip =  ToolTipManager.createToolTip(tip,tipX,tipY) as ToolTip;
			}
			
			private function hideMyTooltip():void{
				if (myTip) {   
					ToolTipManager.destroyToolTip(myTip);   
					myTip = null; 
				}
			}
			
			protected function button_toolTipShowHandler(event:ToolTipEvent):void
			{
				event.toolTip.x=event.currentTarget.x + event.currentTarget.width + 10;
				event.toolTip.y=event.currentTarget.y + (event.currentTarget.height - event.toolTip.height) / 2;
			}
			
			protected function button1_clickHandler(event:MouseEvent):void
			{
				hideMyTooltip();
				showMyTooltip(two, "第二步开始");
			}
			
			protected function button2_clickHandler(event:MouseEvent):void
			{
				hideMyTooltip();
				showMyTooltip(three, "第三步开始");
			}
			
			protected function button3_clickHandler(event:MouseEvent):void
			{
				hideMyTooltip();
				showMyTooltip(four, "第四步开始");
			}
			
			protected function button4_clickHandler(event:MouseEvent):void
			{
				hideMyTooltip();
			}
			
		]]>
	</fx:Script>
	
	<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
		
		mx|ToolTip {
			borderStyle: "errorTipRight";
			borderColor:black;
			backgroundColor: black;
			backgroundAlpha: 0.8;
			cornerRadius: 5;
			color: white;
			fontSize: 16; 
			paddingBottom:5;
			paddingLeft:5;
			paddingRight:5;
			paddingTop:5;
			/* font-family: verdana;*/
			/* borderSkin: ClassReference("MyToolTip"); */
		}
		
	</fx:Style>
	
	<s:VGroup gap="100" >
		<s:Button id="testtooltip" label="测试tooltip" width="100" height="100"  toolTip="测试tooltip [[DYNAMIC]]\2 - 解压缩后为 763,122 个字节 - 解压缩后为 763,122 个字节- 解压缩后为 763,122 个字节" toolTipShow="button_toolTipShowHandler(event)"/>
				
		<s:Button id="one" label="第一步" click="button1_clickHandler(event)" />
		<s:Button id="two" label="第二步" click="button2_clickHandler(event)" />
		<s:Button id="three" label="第三步" click="button3_clickHandler(event)" />
		<s:Button id="four" label="完成" click="button4_clickHandler(event)" />
	</s:VGroup>
	
	
</s:Application>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值