dynamically addressing objects
Posted: Wed Oct 17, 2012 3:39 am
Hi all -
I'm really enjoying my adventure learning LiveCode. Making good progress, but still have some lingering questions. Here's a rather basic one that I'd appreciate some help with:
I have created the following handler:
This works just fine. No problems. But it seems like a rather inefficient method of coding.
What I'm wondering, is if there's a way to dynamically create most of this code.
After all, most of it is just repeated, with the only difference being the appending of the number (i.e., "imageX")
And I have the value of that number stored in the global variable.
So... My question, therefore, is how to dynamically create the reference to the image?
Thanks so much...
Joel
I'm really enjoying my adventure learning LiveCode. Making good progress, but still have some lingering questions. Here's a rather basic one that I'd appreciate some help with:
I have created the following handler:
Code: Select all
on showImage which
put gHowMany + 1 into gHowMany
if gHowMany = 1 then
set the filename of image "image1" of card "Main" to the filename of which
set the visible of image "image1" of card "Main" to true
else if gHowMany = 2 then
set the filename of image "image2" of card "Main" to the filename of which
set the visible of image "image2" of card "Main" to true
else
set the filename of image "image3" of card "Main" to the filename of which
set the visible of image "image4" of card "Main" to true
end if
end showImage
What I'm wondering, is if there's a way to dynamically create most of this code.
After all, most of it is just repeated, with the only difference being the appending of the number (i.e., "imageX")
And I have the value of that number stored in the global variable.
So... My question, therefore, is how to dynamically create the reference to the image?
Thanks so much...
Joel