How to set the image of a button

I create a button by GUI Editor. I can use getControlByName to get the Control of button. But how can I go on to set the image of button? I can only get the Control which has no related methods.

The GUI will add a child rect inside the button which holds the image.

Heres how I get it;

let logBtn : any = this.sidebar.getDescendants(false, control => === 'Button1')[0]

logBtn.getDescendants(false, control => === 'Image')[0].source ='../SVG/buttonGraphic.svg'

You should cast it to the correct type to access the dedicated functions.

I cast as any because when you get a comp it returns a control, but you want to access it’s button features which throws false negatives in my IDE.