English 中文(简体)
Button Bar
原标题:Passing a state to the child button of a Flex4 ButtonBar

我有一个Button Bar公司,它有皮肤习俗,为“中产阶级”要求确定了一种习俗。 我的CustomButton BarSkin有一个习俗状态,minimized,我想把这个状态带入我的中Button皮肤,以便改变其设计。

是否可能这样做? 我可以看到我 but子的皮肤。 采用母体文件:目前国家达到最小程度,但确实如此。 任何将皮肤从酒吧传给孩子的路子?

最佳回答

我认为,你应延长缺省代码

问题回答

我最近与 but子公司合作,希望扩大/消除一些违约行为。 我刚刚推出自己的微小部分,而不是扩大和安放;超标准或复制/分发布顿巴法。

public class HButtonBarGroup extends HGroup {

    public function HButtonBarGroup() {
        addEventListener(ElementExistenceEvent.ELEMENT_ADD, refreshSkins);
        super();
        gap = -1;
    }

    private function refreshSkins(event : * = null) : void {
        var buttonCount : int = numElements;

        for (var i : int = 0; i < buttonCount; i++) {
            var button : Button = getElementAt(i) as Button;
            var skinClass : Class

            if ((buttonCount == 0) || (buttonCount > 2 && (i != 0 && i != buttonCount)))
                skinClass = GreyButtonBarMiddleButtonSkin;
            else if (i == 0)
                skinClass = GreyButtonBarFirstButtonSkin;
            else
                skinClass = GreyButtonBarLastButtonSkin;

            Button(getElementAt(i)).setStyle("skinClass", skinClass);
        }
    }
}

这将使你能够做你想要做的多数事情,而不必在布顿·巴、布顿·巴塞和布顿·巴斯金周围 t,除非你想把丁顿/当选的Index挑出来,否则就毫无必要。 海事组织在数据提供人的基础上创建纽芬兰语是一种痛苦,而不是仅仅在数据和元数据交换中宣布纽芬兰语,并在那里指定处理器和其他财产。

我最近需要根据父母状况改变皮肤。 我也使用同样的解决办法,使用CSS。 在你看来,情况如下:

s|ButtonBar:minimized s|ButtonBarButton {
    skinClass: ClassReference("CustomButtonBarSkin");
}
s|ButtonBarButton {
    skinClass: ClassReference("spark.skins.spark.ButtonBarMiddleButtonSkin");
}

:minimized is the Pseudo Selectedor(针对国家)。

Unfortunately, this didn t seem to get picked up by child (bug?) unless I changed styleName on parent element on state change:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"
    styleName.normal="foo" styleName.minimized="foo"
    >

Maybe there is some invalidate-method I should have called on parents state change instead to make child pick up the change, but merely change the styleName to something bogus did the trick.

This is maybe not a widely used technique in Flex due to the fact that Flex 3 only supported basic CSS selectors.

Maybe I m not getting what you re trying to do exactly, but it seems fairly obvious and easy to me. Just have your custome button bar skin set the state of your middle button when the minimized state is active:

<s:Skin>

<s:states>
<s:State name="minimized" />
</s:states>

<s:ButtonBarButton currentState.minimized="someState" />

</s:Skin>

Get it?





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签