Call the JavaScript script code

Hi Toan Le

I’m trying to call the JavaScript script code (fireworks) to “onSceneActivated” but I can’t call just the canvas Div for the scene.

I’m building a game and I would like to associate this effect when the player clicks on the right answer, fireworks appears.

Here I send the project, give me your opinion.

regards Charlie
fireworks.zip (12.3 KB)

Hi Charlie,

The canvas is in an iframe (in HTML_Widget_1) so you can’t get it from the main document (in onSceneActivated) by using document.querySelector('.fireworks');

You can delete the HTML widget and use a Custom Element instead:

image

Please also exclude the script JS resource from the main document because the canvas is not available when this script is invoked, and you already clone it in onSceneActivated:
image

Regards

Hi Toan Le

Thanks again for the tip

Regards Charlie