apache-flex - 扩展 Flex Spark Button 以包含可单击的复选框

标签 apache-flex button actionscript skin flex-spark

我使用 Sparkskin 作为按钮,在按钮上放置一个复选框。

当前按钮正在接收鼠标点击,并且复选框不可选择。

我希望用户能够选择/取消选择该复选框。

我是否需要在 Sparkskin 中设置某些内容或覆盖某个函数才能实现此目的?

最佳答案

首先,创建扩展 Spark Button 的自定义按钮。将 mouseChildren 属性设置为 true(在 super() 调用之后)。重写mouseEventHandler方法,该方法处理按钮的所有鼠标事件。检查事件的 target,如果 target 是您的复选框,则不要调用 super.mouseEventHandler,以防您不想要按钮选中复选框时单击。

 public class MyButton extends Button {
        [SkinPart]
        public var checkBox:CheckBox;

        public function MyButton() {
            super();
            mouseChildren = true;
        }

        override protected function mouseEventHandler(event:Event):void {
            if (event.target != checkBox)
                super.mouseEventHandler(event);
            }
        }
 }

关于apache-flex - 扩展 Flex Spark Button 以包含可单击的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25319486/

相关文章:

apache-flex - 弹性 3 : How do I get the DataGridColumn's dataField in its ItemRenderer?

apache-flex - 如何使 Ant 生成的 swf 尽可能小?

c# backgroundworker 无法使用我希望它执行的代码

javascript - 需要根据操作系统修改PDF内的链接目标

algorithm - 在 Flex 中验证我们邮政编码的最有效方法

flash - 无法运行 Flash Builder 4.6 调试器

android - 如何在ViewPager中设置OnClickListener

jquery - 为什么追加只能执行一次?

flash - 参数错误 : Error #2015: Invalid BitmapData

javascript - ActionScript 到 Javascript 交叉编译器