1. 程式人生 > >Flex設置LinkButton的背景色

Flex設置LinkButton的背景色

div 源代碼 ati size 調用 fcm oid mil begin

1、設計思路

因為Flex中沒有設置LinkButton的背景色的屬性,如今得從兩個方面入手:第一,直接通過調用樣式方法畫出LinkButton的背景色;第二,設置LinkButton的背景圖片。這裏,講述的是第一種方法


2、設計源代碼

<?

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" creationComplete="initHandler(event)"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.events.FlexEvent; /** * 初始化函數 */ protected function initHandler(event:FlexEvent):void { myLinkButton.graphics.beginFill(0x00FF00); myLinkButton.graphics.drawRect(0,0,myLinkButton.width,myLinkButton.height); myLinkButton.graphics.endFill(); } ]]> </fx:Script> <fx:Declarations> <!-- 將非可視元素(比如服務、值對象)放在此處 --> </fx:Declarations> <mx:VBox width="100%"> <mx:LinkButton id="myLinkButton" label="查詢" x="100" y="100"/> </mx:VBox> </s:Application>


3、設計結果

技術分享

Flex設置LinkButton的背景色