Page 1 of 1

icon name usage

Posted: Tue Jul 12, 2016 10:20 pm
by melristau
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:

Re: icon name usage

Posted: Wed Jul 13, 2016 1:14 am
by [-hh]
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

Re: icon name usage

Posted: Wed Jul 13, 2016 5:18 am
by melristau
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

Re: icon name usage

Posted: Wed Jul 13, 2016 8:06 am
by [-hh]
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