剥皮的链接按钮按钮、链接

2023-09-09 21:31:15 作者:峩继续堕落

下面是修改code我这样做。在这里,我已经给皮肤类和放大器;选择颜色。

Here is the modified code i have done. Here i have given the skin class & selection color.

最新code

<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

and the skin class i have used as per below 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;
            }
        }
    }
}
}

但它不工作。如果我会选择一个按钮,那么其他人也越来越突出了它。

But its not working. If i will select one button then others are also getting highlighted with it.

推荐答案

用法:

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

皮肤改变背景颜色:

Skin for changing background color:

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;
            }
        }
    }
}
}