Trying to set an Image sprite on runtime


Hi, i’m trying to set an sprite of an Image at runtime, but the image just erases the old sprite and becomes white.
Heres a sample project:

I’m referencing the Image and the Sprite asset here:

SpriteSetter.attributes.add(“anonSprite”, {type: “asset”, assetType: “sprite”});
SpriteSetter.attributes.add(‘avatarImage’, {
type: ‘entity’

Then i’m just setting the sprite like this:

this.avatarImage.element.sprite = this.anonSprite.sprite;



Try this…

this.avatarImage.element.sprite = this.anonSprite.resource; // change sprite to resource


It works, thank you!