简体   繁体   English

识别将哪种皮肤应用于按钮

[英]Identifying which skin is applied to button

Hi I have a little problem. 嗨,我有一个小问题。 Is there a way to identify which skin is applied to button? 有没有办法确定将哪种皮肤应用于按钮? I want to use an if-else statements... 我想使用if-else语句...

//if Skins.skin1 is used
    //statements...
//else if Skins.skin2 is used
   //statements...

Spark components that extend SkinnalbleComponent , like the Button have a skin property. 扩展SkinnalbleComponent Spark组件(如Button具有外观属性。 It is set after Flex attaches the the skin to the component. 在Flex将皮肤附着到组件上之后设置。 It could be null, for example, if you create the Button in Actionscript and immediately check the value of skin . 例如,如果您在Actionscript中创建Button并立即检查skin的值,则它可以为null。

You can query the skin for it's type like this: 您可以查询皮肤的类型,如下所示:

if (button.skin is SkinClass1)
{
    // do something
}
else if (button.skin is SkinClass2)
{
    // etc.
}

Or even: 甚至:

switch (true)
{
    case button.skin is SkinClass1:
        // do something
        break;
    case button.skin is SkinClass2:
        //
        break;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM