0

In Flex4 I have a ButtonA with SkinClassA and a ButtonB with SkinClassB. Is it possible to listen in SkinClassA for clicks on ButtonB?

<Components:IconToggleClass id="ButtonA" skinClass="SkinClassA">
<s:Button id="ButtonB" skinClass="SkinClassB"  click="ButtonB_clickHandler(event)" />

// the SkinClassA class
<s:SparkSkin currentStateChanging="onCurrentStateChanging(event)" 
     added="onAddedHandler(event)" >

<!-- host component -->
<fx:Metadata>
<![CDATA[  
    [HostComponent("Components.IconToggleClass")]
 ]]>
</fx:Metadata>

<fx:Script >
    <![CDATA[

    import mx.events.StateChangeEvent;

    private function onAddedHandler(event:Event):void
    {
        setIcon("iconDefault");
    }
//I want something like this:
    private function onButtonBClick():void
    {
       //do something
    }

     ]]>

</fx:Script>
4

1 回答 1

0

您应该在主机组件中监听 click 事件并相应地更新皮肤状态。

private function onButtonBClick(event:MouseEvent):void {
   beenClicked = true;
   invalidateSkinState();
}

protected override function getCurrentSkinState():String {
   if (beenClicked) 
       return "clicked";
   else
       return super.getCurrentSkinState();
}

然后,您应该在您的皮肤中实现单击状态,并在其中加载第二个图标。

于 2013-01-21T14:32:32.860 回答