Button images
Jim Hurley
jhurley at infostations.com
Sat Feb 15 14:19:01 EST 2003
>
> Greg Wills wrote:
>
>Hi all
>
>This should be easy but I am struggling with this at the moment. I
>have been following the discussion on graphics in buttons with
>interest, however I am stuck at step one!
>
>I have a stack "Display" and a sub-stack "GraphicsStore". I can set a
>button id 1005 (in the "Display" stack) to a image id 1234 in the
>substack via the properties palette, however I am having trouble
>changing the image via a script.
>
>I can remove the icon by;
>
>set the icon of button id 1005 to image id 0
>
>however
>
>set the icon of button id 1005 to image id 1234
>or
>set the icon of button id 1005 to image id 1234 of substack "GraphicsStore"
>
>is not doing a thing.
>
>I would appreciate any clues as to the correct syntax for changing
>the button icons.
>
>Thanks
>
>Greg
Greg,
One way to set the button icons programmatically is to run the
"setUp" handler below. It presumes that each button which is to
receive an image icon has been given the same name as the image in
the substack. It will run through all the cards in the main stack and
if it finds a button whose name corresponds to an image in the
substack, it will assign the image id to the button. (All images are
located on the one card in the substack. It is relatively quick and
painless.
On setUp
Lock screen
repeat with i =1 to the number of cards
set the defaultstack to "myStack"
go to card i
repeat with j = 1 to the number of buttons
put the short name of button j into tButtonName
set the defaultstack to "mySubstack"
if there is an image tButtonName then put the id of image
tButtonName into tImageID
set the defaultstack to "images"
set the icon of button j to tImageID
end repeat
end repeat
unlock screen
end setUp
Jim Hurley
More information about the use-livecode
mailing list