欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-21 23:25:28
先看效果图: 其中test.mxml为: 复制代码 代码如下:
先看效果图:
flex自定义按钮皮肤示例附图
其中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 按钮皮肤