Use images of a stack in another stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Use images of a stack in another stack

Post by AlessioForconi » Wed Apr 24, 2019 8:20 am

Hello,

I have images in a card that I use without problems through the property inspector.

I would like to use them also in another card of a different stack, but from the property inspector do not appear, do I have to duplicate the card in the stack in use or do I have to call them by code?

Thank you

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Use images of a stack in another stack

Post by jmburnod » Wed Apr 24, 2019 8:39 am

Hi Alessio,
You may set the text of your destination image to the text of the source image if it is a non referenced image.

Code: Select all

set the text of image "myImg" of stack "myStackDest" to the text of image "OneImg" of stack "myStackSource"
Using external file is an other way. External file can be use by several stacks. 8). You have to create a common folder with image files.

Code: Select all

 set the filename of image "myImg" of stack "myStackDest to MyPathfile.
Best regards
Jean-Marc
https://alternatic.ch

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Use images of a stack in another stack

Post by Klaus » Wed Apr 24, 2019 11:04 am

We cannot use any LC object from one stack in anohter stack.
Why do your think images would behave differently? :D

The ONLY way to do so is to use a button (in stack A ) and set its ID to the id of the image from the other stack (stack B). But that will only work if there is no image in the stack (stack A) with the same ID already.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 11:09 am

I'm curious, wouldn't grouping the images and setting the shared make them accessible anywhere? Like a bg that isn't placed on every new card.
Image

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Use images of a stack in another stack

Post by Klaus » Wed Apr 24, 2019 11:10 am

Yes, but on a "per stack" base!

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 11:12 am

Ok, you lost me. I should also point out I just woke up Image
Image

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Use images of a stack in another stack

Post by Klaus » Wed Apr 24, 2019 11:27 am

Excuses, excuses, excuses... :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 12:56 pm

:mrgreen:

Actually, if I remember something Jacque said once correctly, you *could* put all the images in a bg group on the main stack, then delete the group and it (and the images) would still be there.

Hope I got that right :roll:
Image

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Use images of a stack in another stack

Post by Klaus » Wed Apr 24, 2019 1:18 pm

Since LC loads the complete stack into RAM, this makes sense.
But I would surely not deliver a (commercial) standalone with this concept! :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 1:25 pm

Yes, that could be bad :P

I'm curious about something else I haven't really experimented with (the list is legion in size). If you had a library stack with your images, would it be workable that way?
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Use images of a stack in another stack

Post by jacque » Wed Apr 24, 2019 3:53 pm

bogs wrote:
Wed Apr 24, 2019 12:56 pm
Actually, if I remember something Jacque said once correctly, you *could* put all the images in a bg group on the main stack, then delete the group and it (and the images) would still be there.

Hope I got that right :roll:
Almost. You don't delete the group, you just remove it from the one card it's on. The group remains as part of the stack that way but isn't displayed anywhere. {This is how MC uses resources from imported HC stacks.) All cards, buttons, etc. in the stack can use the images as icons. If the stack is put in use, then other stacks can also use the images if their buttons are set up with matching icon IDs.

I have a large project that downloads stacks on demand, and they all use the icons stored in the mainstack/app this way. You do have to set the image IDs to very large numbers to avoid ID conflicts, I think mine are in the 500,000 range and up.

Edit: this is essentially your library stack idea and yes, it does work. But I think the OP was looking for image sharing rather than icons. In that case, copying or setting the imageData works. Or you could just make a transparent button as large as the image and set its icon.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 4:07 pm

jacque wrote:
Wed Apr 24, 2019 3:53 pm
bogs wrote:
Wed Apr 24, 2019 12:56 pm
Actually, if I remember something Jacque said once correctly, you *could* put all the images in a bg group on the main stack, then delete the group and it (and the images) would still be there.

Hope I got that right :roll:
Almost. You don't delete the group, you just remove it from the one card it's on. The group remains as part of the stack that way but isn't displayed anywhere.
OOOOOooooohhhhhhh, I see. When you said 'remove', I was thinking remove by deletion. How do you remove it without deleting it? Just choose 'cut object' ?
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Use images of a stack in another stack

Post by jacque » Wed Apr 24, 2019 4:39 pm

Just as you can place a group on a card, you can also remove it from the card. The options are in the Objects menu. Select the group and choose Remove from the menu. Or you can use the command from the message box (see "remove" in the dictionary.)

This method does mean that you have to temporarily place the group again if you want to edit it, then remove it when you're done.

BTW, I'm using this method in a commercial product that's been sold for years and haven't had any trouble with it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Use images of a stack in another stack

Post by bogs » Wed Apr 24, 2019 4:47 pm

jacque wrote:
Wed Apr 24, 2019 4:39 pm
Just as you can place a group on a card, you can also remove it from the card. The options are in the Objects menu.
LOL!

I think I need to spend a bit more time in (any) version of Lc/rev, in Mc, there is no 'Objects' menu, I don't think I ever even looked at it in the rev/lc menus :oops: (Something I'll need to go add to Mc :D )
Selection_001.png
We don't need no steenkeen objects...Oh wait...
Image

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Use images of a stack in another stack

Post by AlessioForconi » Thu Apr 25, 2019 6:37 am

It's nice that my questions give way to debates that are always so shared :D

Turning to the question, given that the images are few and I use them in some buttons, could it be corrected if I recreated the card in the new stack or is it wrong?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”