Skip to main content
Participant
July 7, 2022
Question

Component Parameters Click Image

  • July 7, 2022
  • 1 reply
  • 103 views

How can I make the image clickable?

not working

How can I write code with document.queryselector?

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    July 7, 2022

    Hi.

     

    You could write something like this:

    stage.on("drawend", function() // components are not immediately available so we have to listen for the drawend event
    {
    	var image = document.getElementById("yourComponent"); // "yourComponent" is the instance name of the Image component instance in the Properties panel
    	
    	image.addEventListener("click", function()
    	{
    		console.log("clicked");
    	});
    }, null, true);

     

    But do you really need a component for this? Why just don't turn the bitmap into a symbol and add a listener to it?

     

    Regards,

    JC