on clicked theObject help!

Hi,

I’m trying to make my first studio project.
It’s a simple controller for a TV app called TheTube.

My applescript is

on clicked theObject
	if the name of theObject is "up" then 
		tell application "TheTube"
			next channel
		end tell
	end if
end clicked

Which throws an error when I click on the object named up, saying that no result was returned from some part of this expression -2673.

But without the objects, this works:

tell application “TheTube”
next channel
end tell

So something about trying to take a click on a button to do this is messing me up.

Lil help?

go in to interface builder and check that you named your button up and that it’s connected to your applescript.

Thanks for the suggestion.

In the Inspector attributes, the button’s title is ‘up’

In the Inspector applescript, the button is an action, clicked, and the script tuberemote.applescript checked.

Do you have any other suggestions?

Thanks!

what you are doing is trying to get your app to do it’s thing using the “Title” of theObject, ie" the title of your button is “up”, the script below will address this.

on clicked theObject
	if the title of theObject is "up" then
		tell application "TextEdit"
			activate
		end tell
	end if
end clicked

You could also goto Inspector applescript, and put “up” in the “Name” area their, and use the script below to have your app do it’s thing,

on clicked theObject
if the name of theObject is "up" then
tell application "TextEdit"
activate
end tell
end if
end clicked

Exactly, name and title are 2 different things. I prefer to use name. To use name click your object in IB, go to the applescript inspector and just above where you checked of clicked, there is a text field where you “name” your button. Naming it allows you to change the title of the buttons whilst always retaining the same name. This will help you create much tidier code.