0

我使用 FB4.6 并尝试在我的按钮上应用填充颜色。

package fr.int.component.customNavTab
{
    import mx.controls.Button;
    import mx.controls.ToggleButtonBar;
    import mx.core.IFlexDisplayObject;
    import mx.states.OverrideBase;

    public class IconToggleButtonBar extends ToggleButtonBar

    {

        public function IconToggleButtonBar()
        {
            super();

        }

        [Inspectable (enumeration='left,right,top,bottom', defaultValue='left')]  
        public var labelPlacement:String = 'left';  
        public var color:uint;


        override protected function createNavItem(label:String, icon:Class=null):IFlexDisplayObject
        {
            var b:Button = Button (super.createNavItem(label,icon));
            b.labelPlacement = labelPlacement;

            b.setStyle('fillColors', [0x86C543, 0xE6E6E6]);
            return b;
        }



    }
}

但这对我的按钮没有影响。

你能帮助我吗?

谢谢

4

2 回答 2

2

你传入一个字符串'[0x86C543, 0xE6E6E6]'你需要一个数组。[] 括号表示一个数组,但通过将其放在引号中,它会作为字符串读入。

将此更改为

b.setStyle('fillColors', [0x86C543, 0xE6E6E6]);
于 2012-04-17T18:46:17.980 回答
0

fillColorsmx:Button仅适用于 Halo 主题的作品。所以你需要使用 Flex 3 SDK 或在 Flex 4 http://blog.flexexamples.com/2009/07/14/using-the-halo-theme-in-flex-4/中尝试类似的东西

编辑:这是一个例子。尝试使用 Flex 4 SDK 创建项目并将此代码放入应用程序:

<?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" minWidth="955" minHeight="600">
    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";
        mx|Button{
            fillColors: #FF0000, #00FF00
        }
    </fx:Style>
    <mx:Button />
</s:Application>

会有一个警告The style 'fillColors' is only supported by type 'mx.controls.Button' with the theme(s) 'halo'.而且你正在使用它并不重要,mx:Button你需要使用光环主题的事实很重要。所以如果你想改变 fillColorsmx:Button你有我之前发布过的 2 个选择

于 2012-04-18T13:15:16.027 回答