Search code examples
apache-flexstates

Flex: Right click button causes state change


Right click on a Spark Button triggers a state change from "over" to "up".

Instead I would like the state to be "down", so the button behaves the same on left or rightclick.

Is this possible?


Solution

  • Yes it is!

    var b:Boolean;
    
    protected function rightMouseDown(e:MouseEvent):void {
        b = true;
    }
    
    protected function rightMouseUp(e:MouseEvent):void {
        b = false;
    }
    
    override public function setCurrentState(stateName:String, playTransition:Boolean = true):void {
        if (!b) {
            super.setCurrentState(stateName, playTransition);
        } else {
            super.setCurrentState(...);
        }
    }