I've been through Shanes book, and looked at the Chapter 10 resources, but what I'm trying to do seems outside of those.
I've got four images that I'd like to set a buttons image to at various stages. I cannot work out what's wrong with my code.
on setVolume_(sender)
tell application "iTunes" to set sound volume to my actualVolume as integer
if my actualVolume as integer > 80 then
set theImage to pathForResource_ofType_("Speaker",".png")
set theURL to fileURLWithPath_(theImage)
set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
else
if my actualVolume as integer > 40 then
set theImage to pathForResource_ofType_("Speaker medium",".png")
set theURL to fileURLWithPath_(theImage)
set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
else
if my actualVolume as integer > 1 then
set theImage to pathForResource_ofType_("Speaker low",".png")
set theURL to fileURLWithPath_(theImage)
set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
else
set theImage to pathForResource_ofType_("Speaker off",".png")
set theURL to fileURLWithPath_(theImage)
set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
end if
end if
end if
end setVolume_