• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 17. Handlers And Events > Handlers and Handler Hierarchy

Handlers and Handler Hierarchy

You can think of handlers as instruction sheets for various tasks. Each handler can perform one or more instructions, in a specified order, and can return information to wherever the handler was called from. Handlers can optionally take arguments, also known as parameters, which are additional values passed to the handler when it is called and which provide additional information the handler needs to complete its task. For example, the setStatus handler you used earlier in the lesson took one parameter: newStatus. By itself, setStatus doesn't know what to change the Status text to, but by passing in the newStatus value, you give it the information it needs.

Each handler has a name that is used to invoke it. In the script, the name is preceded by the keyword on. The Events movie, for example, contains a handler to handle the mouseUp message. That handler is called the mouseUp handler or the on mouseUp handler. You can name a handler almost anything you want, so long as the name conforms to the language rules, which specify that the name must start with a letter and can include only letters, numbers, and underscore (_) characters. Some names, however, already have assigned uses. When Director events occur, Director tries to invoke handlers with certain names for each event. For instance, when a movie starts, Director calls a startMovie handler, which may or may not exist. If you have written a handler called startMovie and it is available in a movie script, then Director will invoke that handler automatically when the movie starts. If no such handler exists, nothing special happens; Director tries to call handlers, but you aren't required to have a handler for every event.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint