在Flex4中,我有一个带SkinClassA的Button和一个带SkinClassB的Button。是否可以在SkinClassA中收听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>
答案 0 :(得分:0)
您应该监听hostcomponent中的click事件并相应地更新skinstate。
private function onButtonBClick(event:MouseEvent):void {
beenClicked = true;
invalidateSkinState();
}
protected override function getCurrentSkinState():String {
if (beenClicked)
return "clicked";
else
return super.getCurrentSkinState();
}
在你的皮肤中你应该实现点击的状态,你加载第二个图标。