Open
Description
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
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";
}
}