Flash toggle button

后端 未结 3 1739
野性不改
野性不改 2021-01-14 09:37

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

3条回答
  •  深忆病人
    2021-01-14 09:55

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

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

提交回复
热议问题