本文介绍了闪光灯切换按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Flash / AS3一键开启和关闭之间切换。所以,我很高兴地看到, 按钮 类具有的属性,让我有这种行为。我不太高兴地看到,我所得到的,当我做一些东西在Flash文件按钮是的类,它并没有这样的选择。

I need a button in Flash/AS3 that toggles between on and off. So I was glad to see that the Button class has the toggle property that lets me have that behavior. I was less happy to see that what I get when I make something a "button" in the Flash file is an instance of SimpleButton class, which does not have that option.

有没有办法要么得到一个Button实例从.fla文件,或获取的SimpleButton表现为一个切换?

Is there a way to either get a Button instance from the .fla, or get the SimpleButton to behave as a toggle?

推荐答案

下面是我如何codeD解决此我的方式:

Here's how I coded my way around this:

private buttonState:Boolean;

private function buttonToggle(button:SimpleButton){
    var currDown:DisplayObject = button.downState;
    button.downState = button.upState;
    button.upState = currDown;
    buttonState = !buttonState;
}

private function clickEvent(e:MouseEvent){
    buttonToggle(e.target);
}

我没有把code。在 clickEvent 的功能,因为这可以让我从code别处切换按钮。

I didn't put the code in the clickEvent function, because this allows me to toggle the button from elsewhere in the code.

这篇关于闪光灯切换按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 17:01