类似百度添加或删除收藏的效果

 

类似ToolTip组件: FavoritesToolTipComp.mxml

<s:SkinnableContainer...>
  <s:Group left="0" right="0" top="0" bottom="0">
    <s:Rect width="100%" height="100%">
      <s:fill>
	<s:SolidColor color="#FFFECC" />
      </s:fill>
      <s:stroke>
	<s:SolidColorStroke color="#DFB259" weight="1" caps="round" joints="round" />
      </s:stroke>
    </s:Rect>
		
    <s:Label id="favorLabel" left="5" right="5" top="10" bottom="10"
	 fontFamily="宋体" fontSize="12" color="#990000"  />
		
  </s:Group>
	
  <s:Path winding="nonZero"	horizontalCenter="0" top="-3.7"
	data="M0 3.6665 4.16699 3.6665 7.83398 0 11.834 3.6665 16.834 3.6665">
    <s:fill>
      <s:SolidColor color="#FFFECC"/>
    </s:fill>
    <s:stroke>
      <s:SolidColorStroke weight="1" caps="none" joints="miter" miterLimit="10" color="#DFB259"/>
    </s:stroke>
  </s:Path>

</s:SkinnableContainer>


主程序调用FavoritesToolTipComp组件

<s:Application xmlns:component="component.*" ... >
	<fx:Script>
		<![CDATA[
			import component.FavoritesToolTipComp;
			import flash.utils.Timer;
			import mx.core.FlexGlobals;
			
			protected function button1_clickHandler(event:MouseEvent):void
			{
				var favorToolTip:FavoritesToolTipComp=new FavoritesToolTipComp();
				FlexGlobals.topLevelApplication.addElement(favorToolTip);
				favorToolTip.left=10;
				favorToolTip.top=100;
				var favorTime:Timer=new Timer(5000,1);
				
				if(favorBtn.selected==true){
					favorToolTip.visible=favorToolTip.includeInLayout=true;
					favorToolTip.favorLabel.text="成功添加到收藏夹";					
					favorTime.addEventListener(TimerEvent.TIMER,function():void{
						favorToolTip.visible=favorToolTip.includeInLayout=false;
					});
					favorTime.start();
					
				}
				else{
					favorToolTip.visible=favorToolTip.includeInLayout=true;
					favorToolTip.favorLabel.text="已从收藏夹中删除";
					favorTime.addEventListener(TimerEvent.TIMER,function():void{
						favorToolTip.visible=favorToolTip.includeInLayout=false;
					});
					favorTime.start();
				}
				
			}
		]]>
	</fx:Script>
	<s:ToggleButton id="favorBtn" label="添加" click="button1_clickHandler(event)" />
</s:Application>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值