单击时如何使按钮保持在上下状态?

时间:2013-10-25 19:41:08

标签: actionscript-3 flash button sticky

单击时如何使按钮保持在向下或超过状态,再次单击时再返回到向上状态?

1 个答案:

答案 0 :(得分:0)

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)
}