Copy link to clipboard
Copied
I have set of buttons, normally I would let button stay as it is and call its instance name to add event listener. But this time I tried to make it moving, I created a classic tween to it, then named the classic tween instance name.
Normally, this is the code:
this.btn_name.on("click", function() {...});
So this time, I just add the tween's instance name before it:
this.tween_name.btn_name.on("click", function() {...});
And it's not working anymore. I can't seem to find the answer in the community. Please help.
Copy link to clipboard
Copied
Hi.
You can just add the event listener to the button like you would normally do without worrying about the tween.
Or is there something else going on?
Regards,
JC
Copy link to clipboard
Copied
No, it's not working. I have tried to put the code inside the tween but still not working.
Here is the page, could you please check it.
https://xenodochial-brahmagupta-9e2db9.netlify.app/
In "Projects" section, I use buttons for my work and I want to redirect the web when click on it.
Copy link to clipboard
Copied
What I have tried:
- Named the tween and put the code in root. (root.tween_name.button_name.onclick)
- Skip the tween name, code still in root. (root.button_name.onclick)
- Put the code inside tween (this.button_name.onclick)
It's work if I don't have tween on buttons layer but that's not what I want.