Copy link to clipboard
Copied
Hi
Rather new to animate cc so let me try and explain what I am trying to achieve.
I have html5 canvas file with a map in it. I would like it that when you click on the map apart from the animation that plays it will trigger an event on the webpage where its displayed so that the a java script on the site displays a text div.
I have the code for navigating the map working just fine. Its just the code for triggering an event outside the animate file. I dont know if that is possible to have the animate file trigger events outside the file itself and how would the code look like?
Thank you for all your inputs.
1 Correct answer
Hi.
What you can do is to dispatch an event and then set a HTML5 DOM element to listen to it.
Something like this:
window.dispatchEvent(new CustomEvent("eventname", {detail:{prop:"value"}}));
window.addEventListener("eventname", yourDisplayDivTextFunction.bind(this));
It can be the window itself, document... whatever you need.
Regards,
JC
Copy link to clipboard
Copied
Can you provide details on the purpose of such a trigger and what you are hoping to achieve?
Copy link to clipboard
Copied
Hi.
What you can do is to dispatch an event and then set a HTML5 DOM element to listen to it.
Something like this:
window.dispatchEvent(new CustomEvent("eventname", {detail:{prop:"value"}}));
window.addEventListener("eventname", yourDisplayDivTextFunction.bind(this));
It can be the window itself, document... whatever you need.
Regards,
JC
Copy link to clipboard
Copied
Thank you so much was just what i was looking for.
Copy link to clipboard
Copied
You're welcome!

