icon name usage

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
melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

icon name usage

Post by melristau » Tue Jul 12, 2016 10:20 pm

I'm understanding control of the image associated with a button using the icon ID:
on mouseUp
if the icon of me is 1060 then set the icon of me to 1061
else if the icon of me is 1061 then set the icon of me to 1060
end mouseUp

but not understanding how to utilize the icon name to do similar.
this errors out:
on mouseUp
if the name of the icon of me is "nnnyH-...i.jpg" then set the icon of me to "nnnnH-.....jpg"
else if the icon of me is "nnnnH-.....jpg" then set the icon of me to "nnnyH-...i.jpg"
end mouseUp

What am I not understanding?
Need help with scripting the change of a button's image by referencing its existing image name.
:oops:
rebuilding visual programming app originally created in 1993 as Hypercard stack

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: icon name usage

Post by [-hh] » Wed Jul 13, 2016 1:14 am

One possibility:

Code: Select all

on mouseUp
  if the icon of me is the short id of img "alerthand.gif" then
    set icon of me to "exclamation.gif"
  else set icon of me to "alerthand.gif"
end mouseUp
shiftLock happens

melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

Re: icon name usage

Post by melristau » Wed Jul 13, 2016 5:18 am

Thanks -hh
With your suggestion, this is now working for me:

Code: Select all

put the short name of img (the icon of me) into gName
rebuilding visual programming app originally created in 1993 as Hypercard stack

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: icon name usage

Post by [-hh] » Wed Jul 13, 2016 8:06 am

As "the icon" returns the short id of an image you probably forgot to type "id"?

Code: Select all

put the short name of img id (the icon of me) into gName
shiftLock happens

Post Reply