Switching set of referenced images

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
Mistfall
Posts: 23
Joined: Tue Dec 30, 2008 1:26 pm
Contact:

Switching set of referenced images

Post by Mistfall » Mon Sep 13, 2010 4:48 am

I'm a non-programmer and new at this, so please forgive me if this is a no-brainer.

I'm using referenced images to create the look-and-feel for a rev application. I envision creating the stack with a default folder of images, and offering the user the ability to choose among several different sets of themed images if he or she desires. Each set of images would be stored in its own folder at the same directory level as the default set.

The images would be used in four different groups. One of these groups would be behaving as a "background" and used on multiple cards.

What is the easiest way to implement such switch-ability?

Thank you for any tips!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Switching set of referenced images

Post by Klaus » Wed Sep 15, 2010 11:35 am

Hi Mistfall,

I have done something like a long time ago.
The ideal scenario would be:
SAME name for the images, only differnt folder names.

Example:
You have a couple of folders named "skin1", "skin2" etc.
All the images have the same name like "image1.jpg", "image2.jpg" etc.

THEN you can easily create a repeat loop that changes the appropriate FOLDERNAME in the filename of your images like this
when switching the "image set" to "skin2":

Code: Select all

...
## Change the "image set" on one card
set itemdel to "/"
repeat with i = 1 to the num of images
  put the filename of img i into tFilename
  ## Volume/Folder1/folder2/skin1/image1.jpg

  put "skin2" into item -2 of tFilename
  ## Volume/Folder1/folder2/skin2/image1.jpg !!
  
  set the filename of img 1 to tFilename
end repeat
...
Know what I mean?
A clever naming convention is EVERYTHING in cases like this!

Hope that helps.


Best

Klaus

Bantymom
Posts: 73
Joined: Fri Aug 27, 2010 4:32 am

Re: Switching set of referenced images

Post by Bantymom » Thu Sep 16, 2010 6:07 am

That might work for me too, the same idea, for linking a list of words and two images for each level of difficulty in the spelling game I am making for my students! Store the information for each level on its own card or folder?
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Switching set of referenced images

Post by Klaus » Thu Sep 16, 2010 11:52 am

Hi Bantymom,
Bantymom wrote:... Store the information for each level on its own card or folder?
I am not sure if I understand your question?
Store it wherever it makes sense to you :D


Best

Klaus

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Switching set of referenced images

Post by shadowslash » Thu Sep 16, 2010 4:40 pm

Another option might be to create/edit Property Profiles... Image
Parañaque, Philippines
Image
Image

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Switching set of referenced images

Post by Klaus » Thu Sep 16, 2010 7:58 pm

shadowslash wrote:Another option might be to create/edit Property Profiles... Image
Yep, maybe, but my script is dated a time long before these kind of modern comforts :D

Mistfall
Posts: 23
Joined: Tue Dec 30, 2008 1:26 pm
Contact:

Thank you

Post by Mistfall » Fri Sep 17, 2010 12:09 pm

Thank you, Klaus, that will be extremely helpful! Just what I needed!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Switching set of referenced images

Post by Klaus » Fri Sep 17, 2010 12:18 pm

Hi all,

glad I could help!

Addition:
It might be a good idea to add a "lock screen" before and a "unlock screen" after the "repeat" loop!


Best

Klaus

Post Reply