【问题标题】:How make a button stay in over or down state when clicked?单击时如何使按钮保持在上或下状态?
【发布时间】:2013-10-26 04:53:45
【问题描述】:

如何使按钮在单击时保持向下或向上状态,然后在再次单击时恢复到向上状态?

【问题讨论】:

  • 它是 Flash 组件按钮、从 simpleButton 类扩展的按钮,还是您自己制作的全新按钮?

标签: actionscript-3 flash button sticky


【解决方案1】:
import flash.events.Event;

var clicked = false; //Make a variable that stores the current state.

button_mc.addEventListener(MouseEvent.CLICK, toggleState);

function toggleState(e:Event){
    clicked = !clicked; //Toggle the current state

    (clicked) ? button_mc.gotoAndPlay(2) : button_mc.gotoAndPlay(1);
    //if clicked is true, go to the clicked frame in the button
    //(you might have flags, in which case, name them in quotes, 
    //butt_mc.gotoAndPlay("clicked")), otherwise go to the first 
    //frame (which should be the upstate)
}

【讨论】:

    猜你喜欢
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 2015-10-17
    相关资源
    最近更新 更多