Check this out:
I've written an example over here, using the JavaScript SDK, just right-click to check the source: http://jordymoors.nl/particle/demos/function_button.html