I have 10 buttons. Each button does the same thing, except for one small variation. Obviously, it makes sense to use a command to do the processing and pass in any parameters.
So, for the button "buttonNumber1", the code looks like this:
on mouseDown
displayNumber 1
end mouseDown
In my card code, I have :
command displayNumber thisNumber
local baseIcon = 7097
local thisButton
put "buttonNumber" & thisNumber into thisButton
set the icon of button thisButton to baseIcon + 10 + thisNumber
play specialFolderPath("engine") &"/assets/audio/number" & thisNumber & ".m4a"
wait 1.5 seconds
set the icon of button thisButton to 0
end displayNumber
It doesn't really matter what the command is doing, but just for completeness, it create sand puts the name of the button into the variable thisButton and sets the icon of the button to an image. It then plays an audio file (stored in /assests/audio), waits for the sound to complete and resets the icon of the button to nothing.
Running within LiveCode, this works fine.
Running in the simulator and on a real device, nothing happens.
The command displayNumber and the button are in the same card.
In an experiment to see if there is a scope problem, I put the definition on the command at the button level scope and everything worked fine.
Any help would be appreciated as the only alternative I will have is to duplicate the same code for every button which will just grate on my nerves
