1

I have an image in LiveCode that I would like to change to another image when a specific button is pressed. So far, I have tried this -

set the imageSource of image "The_Hangman" to "/HangMan/1.png"

However, I am getting an error code of:

execution error at line n/a (Object: can't set this property)

How do I fix this?

Mark
  • 2,380
  • 11
  • 29
  • 49
CoopDaddio
  • 577
  • 1
  • 5
  • 20

2 Answers2

1

ImageSource refers to the image that is embedded in a text field, which is not what you want.

If you're using imported images, it's not intuitive at all, but the property you want to change is the text property:

set the text of image "abc" to the text of image "xyz"

Setting the text property changes the imageData and alphaData of the designated image at the same time.

If you're using referenced images (images outside your stack), set the fileName property of the image you want to change to the file path of the new image.

Scott Rossi
  • 885
  • 5
  • 6
0

Here's how to do it using external image files:

Let's say you have your images stored in a folder called "images" that is in the same location on your disk as your stack file.

put "hang1.png,hang2.png,hang3.png" into tImgList
put 1 into tCurrImg
set the fileName of image "The_Hangman" to \
   (specialFolderPath("resources") & item tCurrImg of tImgList)

Now by simply changing the value of tCurrImg you can display whichever external image file you want.

Devin
  • 593
  • 1
  • 3
  • 8