Script Objects Question #2

I have a second script objects question for you all. I have two scripts in an applescript studio project. The file - main.applescript - contains:


on launched theObject
set theScript to load script file (second.scpt)
set objectTesting to objectTesting of theScript
tell objectTesting to initialize("test")
end launched

--handler for button 1
on clicked theObject 
  log someProperty of objectTesting
end clicked

The second file - second.applescript - contains:


global objectTesting

--handler for button 2
on clicked theObject
  log someProperty of objectTesting
end clicked

script objectTesting
property someProperty: ""
on intitalize(x)
set someProperty to x
end initialize
end script

When button 1 is clicked, “test” is returned. When button 2 is clicked, “” is returned. I’d like “test” to be returned when button 2 is clicked. That is, I’d like the two on clicked handlers to refer to the same instance of the script object defined in second.applescript.

I hope my question makes sense. I guess what it comes down to is that I’m trying to figure out how to make one instance of a script object accessible to multiple scripts within an applescript studio project. Thanks in advance for any help.

You have have a problem which has already been answerd in What the… Property/button problem. You’ll need a third compiled script.

Hope it helps,
ief2

Thanks for the link. It seems to be nearly a duplicate of my question. Perhaps I have a long lost twin somewhere :-). I take it that there is no way to have the instance handle the interface handlers directly? The only thing I could come up with was to move the on clicked handler for button 2 back to the main.scpt and then have it call a buttonClicked(theObject) handler I created in the instance of the script object.