I feel like there are multiple and different use cases here. I like being able to visually comment / document code, and that it's "live". The ball example, however, could also be expressed as a visual design (not just a visual link), as in Flash or other visual design tool, with the properties and events on the right.
I've been prototyping a very simple designer with a "properties and events" panel, and am trying to find the balance between not writing any code (on event onMouseDown, run action "playNote", argument "C4", for example). In this sense, inactive elements could be placed on the canvas or off-screen like the convention used in Flash. Let my tidy up my Balsamiq and post it here.