Skip to main content
Participant
Jul 7, 2022 7:03 PM UTC
Question

Component Parameters Click Image

How can I make the image clickable?

not working

How can I write code with document.queryselector?

    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    Jul 7, 2022 7:35 PM UTC

    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

    Translate