2013-12-17 35 views
0

這是我所做的修改後的代碼。在這裏我給出了皮膚類&的選擇顏色。剝皮鏈接按鈕

最新的代碼

<mx:LinkButton label="home" styleName="Helvetica22555555" id="homeBtn" fontSize="14" color="#ffffff" 
         useHandCursor="true" buttonMode="true" 
         skin="{com.firstplanet.utils.ULinkButtonSkin}" toggle="true" selectionColor="0xC0D3E2"/> 
     <mx:LinkButton label="course" styleName="Helvetica22555555" id="link" fontSize="14" color="#ffffff" 
         skin="{com.firstplanet.utils.ULinkButtonSkin}" selectionColor="0xC0D3E2"/> 
     <mx:LinkButton label="dashboard" styleName="Helvetica22555555" fontSize="14" color="#ffffff" 
         skin="{com.firstplanet.utils.ULinkButtonSkin}" toggle="true" selectionColor="0xC0D3E2"/> 
     <mx:LinkButton label="logout" styleName="Helvetica22555555" fontSize="14" color="#ffffff" 
         useHandCursor="true" buttonMode="true" 
         skin="{com.firstplanet.utils.ULinkButtonSkin}" toggle="true" selectionColor="0xC0D3E2"/> 

,我已經使用按以下ansers

package com.firstplanet.utils 
{ 
import mx.skins.halo.LinkButtonSkin; 

public class ULinkButtonSkin extends LinkButtonSkin 
{ 
    public function ULinkButtonSkin() 
    { 
     super(); 
    } 

    override protected function updateDisplayList(w:Number, h:Number):void 
    { 
     var cornerRadius:Number = getStyle("cornerRadius"); 
     var selectionColor:uint = getStyle("selectionColor"); 
     graphics.clear(); 

     switch (name) 
     {   
      case "selectedUpSkin": 
      case "selectedOverSkin": 
      case "selectedDownSkin": 
      { 
       drawRoundRect(0, 0, w, h, cornerRadius, selectionColor, 1); 
       break; 
      } 
      default: 
      { 
       super.updateDisplayList(w, h); 
       break; 
      } 
     } 
    } 
} 
} 

但它不工作的皮膚類。如果我選擇一個按鈕,那麼其他人也會突出顯示。

+0

任何想法的傢伙? –

回答

0

用法:

<local:ULinkButton label="Red Link Button" skin="ULinkButtonSkin" toggle="true" selectionColor="0xFF0000"/> 

皮膚改變背景顏色:

package 
{ 
import mx.skins.halo.LinkButtonSkin; 

public class ULinkButtonSkin extends LinkButtonSkin 
{ 
    public function ULinkButtonSkin() 
    { 
     super(); 
    } 

    override protected function updateDisplayList(w:Number, h:Number):void 
    { 
     var cornerRadius:Number = getStyle("cornerRadius"); 
     var selectionColor:uint = getStyle("selectionColor"); 
     graphics.clear(); 

     switch (name) 
     {   
      case "selectedUpSkin": 
      case "selectedOverSkin": 
      case "selectedDownSkin": 
      { 
       drawRoundRect(0, 0, w, h, cornerRadius, selectionColor, 1); 
       break; 
      } 
      default: 
      { 
       super.updateDisplayList(w, h); 
       break; 
      } 
     } 
    } 
} 
} 
+0

好的,我如何在選擇後突出顯示按鈕? –

+0

看來我得到了你的任務錯誤)所以,你想改變選擇狀態的按鈕顏色? – fsbmain

+0

是的,我想突出顯示鏈接按鈕,當它被選中。 –