flex自定义按钮皮肤示例附图

所属分类: 网络编程 / Flex 阅读数: 908
收藏 0 赞 0 分享
先看效果图:

其中Test.mxml为:
复制代码 代码如下:

<?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">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<mx:HBox horizontalCenter="0" verticalCenter="1">
<s:Button id="rightButton" skinClass="components.RightButtonSkin" />
<s:Button id="cancelButton" skinClass="components.CancelButtonSkin" />
<s:Button id="newStyleButton" skinClass="components.NewStyleButtonSkin"/>
<s:Button id="StyleButton" skinClass="components.StyleButtonSkin"/>
</mx:HBox>
</s:Application>

RightButtonSkin.mxml(确定按钮皮肤):
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" alpha.disabled=".5">

<!-- states -->
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>

<!-- border and fill -->
<s:Rect id="rect" radiusX="4" radiusY="4" top="0" right="0"
bottom="0" left="0">
<s:fill>
<s:SolidColor color="0xFAFAFA" color.over="0xEEEEEE"
color.down="0xEEEEEE"/>
</s:fill>
<s:stroke>
<s:SolidColorStroke color="0xCCCCCC" weight="1"/>
</s:stroke>
</s:Rect>

<!-- highlight on top -->
<s:Rect radiusX="4" radiusY="4" top="2" right="2" left="2"
height="50%">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF" alpha=".5"/>
<s:GradientEntry color="0xFFFFFF" alpha=".1"/>
</s:LinearGradient>
</s:fill>
</s:Rect>

<s:Label text="确定" color="0x131313"
textAlign="center"
fontFamily="宋体"
verticalAlign="middle"
horizontalCenter="0" verticalCenter="1"
left="30" right="30" top="8" bottom="8"
/>
</s:Skin>

NewStyleButtonSkin.mxml(新建按钮皮肤):

ps:新建按钮上面那个icon是画上去的
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" alpha.disabled=".5">

<!-- states -->
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>

<!-- border and fill -->
<s:Rect id="rect" radiusX="4" radiusY="4" top="0" right="0"
bottom="0" left="0">
<s:fill>
<s:SolidColor color="0xFAFAFA" color.over="0xEEEEEE" color.down="0xEEEEEE"/>
</s:fill>

<s:stroke>
<s:SolidColorStroke color="0xCCCCCC" weight="1"/>
</s:stroke>
</s:Rect>

<!-- highlight on top -->
<s:Rect radiusX="4" radiusY="4" top="2" right="2" left="2"
height="50%">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF" alpha=".5"/>
<s:GradientEntry color="0xFFFFFF" alpha=".1"/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Graphic>
<s:BitmapImage source="assets/round_plus2.png" left="8" top="6"/>
</s:Graphic>
<s:Label text="新建样式" color="0x131313"
fontFamily="宋体"
left="30" right="20" top="8" bottom="8"
/>

</s:Skin>
更多精彩内容其他人还在看

Flex父子窗口相互调用实现思路及源码

这篇文章主要介绍了Flex父子窗口相互调用实现思路及源码,需要的朋友可以参考下
收藏 0 赞 0 分享

Flex中如何判断是否在组件之外单击

这篇文章主要介绍了在Flex中判断是否在组件之外单击的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

Flex中TitleWindow传值思路及实现

这篇文章主要介绍了Flex中TitleWindow传值思路及实现,需要的朋友可以参考下
收藏 0 赞 0 分享

Flex DataGrid自动编号示例

这篇文章主要介绍了Flex DataGrid如何自动编号,感兴趣的朋友可以参考下
收藏 0 赞 0 分享

Flex DataGrid 伪合并单元格思路及代码

这篇文章主要介绍了Flex DataGrid 伪合并单元格思路及代码,需要的朋友可以参考下
收藏 0 赞 0 分享

Flex读取txt文件中的内容报错原因分析及解决

这篇文章主要介绍了Flex读取txt文件中的内容报错原因分析及解决,需要的朋友可以参考下
收藏 0 赞 0 分享

FLEX ArrayCollection删除过滤的数据问题解决

ArrayCollection添加过滤器后,调用removeItemAt()是无法删除的,下面有个不错的解决方法,大家可以参考下
收藏 0 赞 0 分享

Flex 错误(mx.messaging.messages::RemotingMessage)分析

有时我们在做项目的时候会遇到Flex 错误提示mx.messaging.messages::RemotingMessage,那么产生这个错误的原因是什么呢,今天我们来分析下
收藏 0 赞 0 分享

手把手教你使用flex eclipse整合spring

Flex 是一个高效、免费的开源框架,可用于构建具有表现力的 Web应用程序,这些应用程序利用Adobe Flash Player和Adobe AIR, 可以实现跨浏览器、桌面和操作系统。我们今天就来好好研究下他
收藏 0 赞 0 分享

flex小技巧之加载GIF图片

这篇文章主要是flex使用GIFPlayer加载GIF图片的代码示例,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多