1. A method of attributing behavior to one or more user interface elements in a user interface, wherein the one or more user interface elements are defined in a layered graphical representation specifying a plurality of graphical layers, the method comprising: designating a selection of the graphical layers as a state of the user interface, wherein the selection of the graphical layers defines the one or more user interface elements; setting one or more properties of the state of the user interface to specify an interaction rule associated with the state; recording the state of the user interface and the interaction rule in a persistent datastore.