質問

I am creating a Custom Button extending Spark Button class. The skin class of my button supports 2 skin states, 'Up' and 'Down'.

The custom button works properly when I changes Button's skin states via some measures like dropdown etc. But when I tries to initialise custom button with a skin state, via 'currentState' directives, it throws a run time error

ArgumentError: Undefined state 'down'.

Below is some part of my custom skin class

<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">
<!-- host component -->
<fx:Metadata>
    [HostComponent("components.CustomButton")]
</fx:Metadata>

<s:states>
    <s:State name="up" />
    <s:State name="down" />
</s:states>
    ....
    ....
</s:Skin>

Custom Button class has not much and it just extending Button class plus having some [SkinState] and [SkinPart] directives.

Below is the way I want to use my Custom Button

<comp:CustomButton skinClass="skins.CustomButtonSkin" currentState="down"/>

Thanks, Sumit

役に立ちましたか?

解決

Created a Style property for my custom button and then using it to setting correct Skin State to my skin class from getCurrentSkinState method

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top