Set the opacity of an image element

Ran into an issue and hoping this would solve it. I have an Image Element and I’m trying to set its opacity.

            var ent = this.app.root.findByName('something');
            ent.**componentname**.opacity = 0.5;
            console.log("Image Opacity: " + entAll[i].**componentname**.opacity);

But I can’t seem to get that property or change it (Returns Undefined):
https://developer.playcanvas.com/en/api/pc.ElementComponent.html

In the code you have posted, you have got a reference to the entity, not the element component.

Findbytag might also return an array if I remember correctly. :thinking:

Not sure how to reference the image element component. Printing the object to the console hasn’t helped.

I’ve updated the code above and replaced findByTag with findByName.

What is wrong with ent.element.opacity = 0.5;?

Besides poor documentation? Nothing.