Script Objects Question

Hi All,
I’ve been playing around with using multiple script files and script objects within Applescript Studio and have run into an issue that I haven’t been able to resolve via google. It seems that if I have a script file that looks like this:


script someScript
--some script code
end script

on someHandler()
--some handler code
end someHandler

then xcode is unhappy and crashes, but this:


on someHandler()
--some handler code
end someHandler

script someScript
--some script code
end script

seems to work fine. Did I miss something in the references regarding the order that script objects and handlers must be defined? I wanted to create a preferences script which defines a preferences script object and also would handle the on clicks, on opens, … for a preference panel, but now I’m not sure if I can include the handlers.