I am cloning a button and putting a different image (cat or dog) on it randomly. Based on the image, I want it play a certain audio clip (meow or bark). I tried this but all I get is barking.
on mouseUp
if the icon of me = "cat.jpg" then
play "meow.wav"
else
play "bark.wav"
end if
end mouseUp
Do I have to make different base buttons for the cat and dog? I would prefer to not do that.
Any help is GREATLY appreciated.
Button Scripting based on Image
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Button Scripting based on Image
"the icon of me" will return the image id not the name of the image. If your images have been imported into the stack so that the name of the cat image is cat.jpg and the dog is dog.jpg then you should be able do do something like the following...
if the short name of image id (the icon of me) = "cat.jpg" then...
-- do stuff
else
-- do other stuff
end if
if the short name of image id (the icon of me) = "cat.jpg" then...
-- do stuff
else
-- do other stuff
end if
Re: Button Scripting based on Image
Depends on where that script lives. The "me" will resolve to the object containing the script. If this is in the script of the button it will work. If the code is in the card or stack script, you'll have to replace "me" with "the target".
Code: Select all
if the short name of image id (icon of the target) = "cat.jpg" then
-
- Posts: 58
- Joined: Mon Dec 05, 2011 5:35 pm
Re: Button Scripting based on Image
It's working now! Thanks so much for your help! I really appreciate it.
Re: Button Scripting based on Image
Hi jnmediaGAd195,
I highly recommend to work through these stacks, great learning resources!
http://www.runrev.com/developers/lesson ... nferences/
And welcome to the forum!
Best
Kkaus
I highly recommend to work through these stacks, great learning resources!
http://www.runrev.com/developers/lesson ... nferences/
And welcome to the forum!

Best
Kkaus