Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ButtonHelper "over" and "out" event swaps after changing enabled property of it #941

Open
wanted28496 opened this issue Mar 12, 2018 · 1 comment
Labels

Comments

@wanted28496
Copy link

wanted28496 commented Mar 12, 2018

I am using button helper in my code for creating buttons and after clicking I use the enabled property of the button helper to disable the button and after few seconds I set the enabled property to true but after setting the enabled property to true the properties I had set before clicking gets swap

I have attached images depicting the problem I faced
Image MathFact_1: Depicts my original animation I need at "out"
Image MathFact_2: Shows the over animation
Image MathFact_3: Shows the down animation
Image MathFact_4: Shows the over animation after the click event is fired
Image MathFact_5: Shows the out animation after the click event is fired

mathfact_4
mathfact_5
mathfact_1
mathfact_2
mathfact_3

Here's the code for the same

class BaseButton extends createjs.ButtonHelper{
    currentListener:any;
    currentState: GameButtonState = GameButtonState.INACTIVE;
    preOverState: GameButtonState;
    keyBinds: number[] | null = null;
    public KBListener: any;
    isListening: boolean = false;

    constructor(public target: createjs.MovieClip){
        super(target,"up", "over", "down",false);
        this.target.on("click",this.buttonEvent.bind(this));
    }

    protected addListener(){
        if(!this.isListening)
        {
            console.log(this.currentListener);
            this.isListening=true;
            this.enabled = true;
            this.target.gotoAndStop("up");
        }
    }

protected buttonEvent(event):boolean{
        console.log(event);
        debugger;
        this.removeListener();
        setTimeout( () => {
            this.addListener();
        }, 5000)
        return true;
    }


 protected removeListener():void{
        this.isListening=false;
        this.enabled = false;
        this.setMouseDefault();
    }

 protected setMouseDefault():void{
        let element: HTMLElement | null = window.document.getElementById("canvas");
        element!.style.cursor = "default";
    }
}
@wanted28496
Copy link
Author

the images are in order 4,5,1,2,3

@lannymcnie lannymcnie added the bug label Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants