首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex4 button添图标2

2012-09-02 
flex4 button加图标2? 编写一个buttonSkin.mxml,里面使用BitmapFill将图片引入,然后再在按钮的MXMl文件中

flex4 button加图标2

? 编写一个buttonSkin.mxml,里面使用BitmapFill将图片引入,然后再在按钮的MXMl文件中使用按钮的SkinClass属性将这个buttonSkin.mxml引入。例:
?
?? buttonSkin.mxml

?? <?xml version="1.0" encoding="utf-8"?>
?? <s:Skin xmlns:fx="<a href="http://ns.adobe.com/mxml/2009">http://ns.adobe.com/mxml/2009</a>"
??????????????? xmlns:s="library://ns.adobe.com/flex/spark"
??????????????? xmlns:mx="library://ns.adobe.com/flex/mx">
??????? <!-- host component -->
??????? <fx:Metadata>
??????????????? [HostComponent("spark.components.Button")]
??????? </fx:Metadata>
??????? <fx:Script>
??????????????? <![CDATA[
??????????????????????? import mx.events.FlexEvent;
?
??????????????????????? protected function state1_enterStateHandler(event:FlexEvent):void
??????????????????????? {
??????????????????????????????
??????????????????????? }
?
??????????????? ]]>
??????? </fx:Script>
??????
??????? <s:states>
??????????????? <s:State name="disabled" enterState="state1_enterStateHandler(event)"/>
??????????????? <s:State name="down"/>
??????????????? <s:State name="over"/>
??????????????? <s:State name="up" />
??????? </s:states>
??????
??????? <s:Rect left="0" right="0" top="0" bottom="0" radiusX="1" radiusY="1" rotation="0" alpha="2"? >
??????????????? <s:fill>
??????????????
??????????????????????? <mx:BitmapFill source="@Embed('/img/MC301000202/set.png')"? fillMode="clip"?? />
??????????????? </s:fill>
??????????????
??????
??????? </s:Rect>
</s:Skin>

??? test.mxml

??? <?xml version="1.0" encoding="utf-8"?>
????? <s:WindowedApplication xmlns:fx="<a href="http://ns.adobe.com/mxml/2009">http://ns.adobe.com/mxml/2009</a>"
?????????????????????????????????????????? xmlns:s="library://ns.adobe.com/flex/spark"
?????????????????????????????????????????? xmlns:mx="library://ns.adobe.com/flex/mx">
??????? <s:layout>
??????????????? <s:BasicLayout/>
??????? </s:layout>
??????? <fx:Declarations>
??????????????? <!-- 将非可视元素(例如服务、值对象)放在此处 -->
??????? </fx:Declarations>
??????? <fx:Script>
??????????????? <![CDATA[
??????????????????????? import mx.controls.Alert;
??????????????????????? protected function myClickHandler():void? {
??????????????????????????????? Alert.show("Thanks for submitting.")
??????????????????????? }? ]]>
??????? </fx:Script>
??????? <s:Button id="iconButton"? width="100"? height="30"? x="10"? y="10"? label="Submit to"? skinClass="buttonSkin"? click="myClickHandler()"/>
???? </s:WindowedApplication>

热点排行