您的位置:首页 > 其它

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

2014-02-18 09:39 411 查看


类似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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: