Page 1 of 1

image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 3:05 pm
by Martin-HC
I have a stack of about 50 cards with a number of fields and buttons shared in a group 'collection'. Each card has an image (png), belonging to the same group 'collection', that I load from the internet when the card is created. However, this image is shared between all cards instead of being unique to the card in question. How do I code it so that each card can have its own image? Do I miss a property of the image to be set?

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 3:16 pm
by richmond62
If you want an image to be shared across a number of card you set it as a ckground image.

If you want each card to have its own images you don't do that.

As your collection of butons & so forth is shared across all your cards I assume that you have set that group as a background.

viewtopic.php?t=37407

If you want each card to have its own image then that image will have NOT to belong to your background group.

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 3:30 pm
by Martin-HC
Thanks. When I look at the object properties of my group 'collection' I have checked 'shared group' and 'behave like a background'.

But how can I make the image to not belong to this background group?

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 3:36 pm
by richmond62
Just set a background for each card individually.

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 3:59 pm
by Martin-HC
Sorry, but I don't get what you are saying.

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 5:22 pm
by FourthWorld
Put the image unique to each card on the card instead of the shared background.

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 5:27 pm
by andresdt
Hi @Martin-HC
One option is to remove the image from the shared group and have one image on each card. Another option is to change the image filename to a different file in preOpenCard. For example:

Code: Select all

on preOpenCard
   --
   set the filename of image "theImage" to ("./images/" & the short name of this card)
   --
end preOpenCard
Instead of using the filename property, you can use the imageData or text property and store the images on the stack. Something like this:

Code: Select all

on preOpenCard
   --
   set the text of image "theImage" to the text of image (the short name of this card) of card "imagestore"
   --
end preOpenCard
These are just some ideas on how you can reuse the image you're sharing within the shared group.

Re: image is shared between cards instead of unique to the cards

Posted: Sat Jun 07, 2025 5:33 pm
by richmond62
OK: Uncle Richmond puts his Primary School Teacher hat on . . .

I have made a new stack, and on the first card I have made a group containing 3 buttons and a field:
-
Screenshot 2025-06-07 at 19.18.40.png
-
I have set the 'Shared group' and the 'Behave like a background' to positive.

NOW, having done that, I shall choose a 'background' image for each card.
-
Kardz.jpg
-
I am NOT uploading my stack as its size exceeds the 256 KB (extremely mean) size for files allowed in these forums.

Re: image is shared between cards instead of unique to the cards

Posted: Sun Jun 08, 2025 4:44 pm
by Martin-HC
Thanks to all who replied! Really appreciated it because the solution was indeed to drop the shared image and place an image on each card. Fortunately, that was easy to script. So now I have exactly what I want with a unique image on each card.

Now that the shared image issue has been resolved, I've been able to continue working on my stack all day today where I document my collection of LEGO Star Wars minifigures. I couldn't be happier :-)

As a side note: as an old HC user I still struggle with the complicated concept of backgrounds/groups in LiveCode, which I think I will never understand. :-)

Re: image is shared between cards instead of unique to the cards

Posted: Sun Jun 08, 2025 11:36 pm
by dunbarx
Hi.

It took me a while to migrate, in my thinking, from the HC background object to the LC group object. They are not at all the same, but the group can be coaxed into much the same functionality. All it takes is a bit of practice.

Craig