image is shared between cards instead of unique to the cards

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

image is shared between cards instead of unique to the cards

Post by Martin-HC » Sat Jun 07, 2025 3:05 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Sat Jun 07, 2025 3:16 pm

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.

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

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

Post by Martin-HC » Sat Jun 07, 2025 3:30 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Sat Jun 07, 2025 3:36 pm

Just set a background for each card individually.

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

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

Post by Martin-HC » Sat Jun 07, 2025 3:59 pm

Sorry, but I don't get what you are saying.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Sat Jun 07, 2025 5:22 pm

Put the image unique to each card on the card instead of the shared background.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

andresdt
Posts: 156
Joined: Fri Aug 16, 2019 7:51 pm
Contact:

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

Post by andresdt » Sat Jun 07, 2025 5:27 pm

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.
Be kind, we all have our own wars.
https://torocruzand.com/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10076
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Sat Jun 07, 2025 5:33 pm

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.

Martin-HC
Posts: 11
Joined: Fri Jan 31, 2025 5:27 pm

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

Post by Martin-HC » Sun Jun 08, 2025 4:44 pm

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. :-)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Sun Jun 08, 2025 11:36 pm

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

Post Reply