单击时更改按钮外观

发布于 2024-08-30 06:10:19 字数 1033 浏览 2 评论 0原文

我想在单击按钮时更改按钮外观。

<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx"
          creationComplete="init()">        
    <fx:Script>
        <![CDATA[
            public var _clicked:Boolean = false;

            public function init():void{
                addEventListener(MouseEvent.CLICK, changeButtonClickStatus);            
            }

            public function changeButtonClickStatus(event:MouseEvent):void{
                var that:TopMenuButton = event.currentTarget as TopMenuButton;
                that._clicked = !(that._clicked);

                if(that._clicked == true){
                //change button appearance
                }else{
                //change button appearance
                }
            }   
        ]]>
    </fx:Script>
</s:Button>

有没有使用状态的方法?然后我就可以使用皮肤约定了。 预先感谢您的帮助。

I wahnt to change button appearance when it was clicked.

<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx"
          creationComplete="init()">        
    <fx:Script>
        <![CDATA[
            public var _clicked:Boolean = false;

            public function init():void{
                addEventListener(MouseEvent.CLICK, changeButtonClickStatus);            
            }

            public function changeButtonClickStatus(event:MouseEvent):void{
                var that:TopMenuButton = event.currentTarget as TopMenuButton;
                that._clicked = !(that._clicked);

                if(that._clicked == true){
                //change button appearance
                }else{
                //change button appearance
                }
            }   
        ]]>
    </fx:Script>
</s:Button>

Is there a method using states? I could then use the skin convention.
Thanks in advance for Your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屌丝范 2024-09-06 06:10:19

如果您正在寻找一个可以设置不同状态的切换按钮,则 Flex 4 中已存在

查看 ToggleButtonSkin.mxml 的源代码,了解如何设置不同状态的外观。

If you are looking for a ToggleButton that you can skin the different states of then it already exists in Flex 4.

Check out the source code for ToggleButtonSkin.mxml to see how to skin the different states.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文