getting status of an object

I’m working on a project in Applescript studio that requires a disclosure button to have a different effect every second time it is clicked. that is for example, it starts off not selected, when it is selected it does one thing, when it is clicked again it does the opposite (such as hiding and showing a box).
I would have thought that testing the value returned by ;

 get selected of button "disclosure1"

would be the best way however the line above won’t compile (Can’t get selected of button “disclosure1”. Access not allowed.)
I would think this is not an uncommon problem.
How do i do this?


set tmpState to state of button "disclosure1" of window "Window"

This will return either 0 or 1, for closed (pointing right) or open (pointing down) respectively.


thanks, that works