2013-12-17 37 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

是的,我想突出显示链接按钮,当它被选中。 –