Image placement from Library

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

Post Reply
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Image placement from Library

Post by SteveTX » Sat Jun 29, 2013 2:04 am

Is there a good way to programmatically place an image from the library? I can place and duplicate via button, but if i try to create that same image with matching id of the image in the library, i get a collision. To be clear, I'm not wanting to duplicate any item already placed on the card, I want to bring it from the library to the card via code.

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Image placement from Library

Post by SteveTX » Sat Jun 29, 2013 7:46 am

Let me clarify the context a little bit. 1. all objects on screen need to be created programmatically because the layout is dynamic. 2. I am needing to put everything into groups for control, and since there doesn't seem to be a good way to put things into groups without having created the object in that group or creating duplicates of an existing object (why is there no "put object in grp" ?). The objects in question are images. Is there a way to have an image exist only in the library, and the create the image into the group directly? Is there a better way?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image placement from Library

Post by jmburnod » Sat Jun 29, 2013 9:47 am

Hi Jeff,

In the case you described I use a group like template
I clone it and set the properties of each objects

I read "distractor", your stack is for people with special needs ?

Kind regards
Jean-Marc
https://alternatic.ch

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Image placement from Library

Post by dave_probertGA6e24 » Sat Jun 29, 2013 11:21 am

SteveTX,

This response is assuming that your question was regarding a runtime situation - it's not really obvious from your question.
Also which Library are you referring to?

I think you need to understand what the image Library is. It's a construct in the IDE - and therefore will not exist at runtime. You cannot place items from it onto a card when the Library doesn't exist (at runtime).

What you can do though is make a card that is not shown to the user and put all the images from the Library that you want to use onto that card. The card can be on a substack if required.

Once you have that 'Library' card then you can copy/clone from it onto any card in your application. You can copy into groups very easily too.

Code: Select all

copy image "fred" of card "_hidden_library_card" to group "targetGroupName"
I hope that helps a bit,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image placement from Library

Post by jmburnod » Sat Jun 29, 2013 2:22 pm

Hi,
Good question
I use a folder directory as library. A list of file path.
Once you have this list you can use it to set the filename of images.
In this way you can use the same file for many images
Kind regards
Jean-Marc
https://alternatic.ch

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Image placement from Library

Post by SteveTX » Sat Jun 29, 2013 7:28 pm

That makes some sense. The plain interpretation seems to be that if it isn't used in the stack, directly as an object or referenced by an object (icon/fill/etc), it ceases to exist in the image library. That behavior seems optimized to ensure minimal mainstack library size.

Post Reply