Handlers

A handler defines actions that an mbedlet or a player takes in response to a message. For example, you could create an mbedlet Startup handler that responds to the system-generated Startup message. The handler would specify the actions that the mbedlet takes upon receiving the Startup message.

To define a handler, you:

A handler can respond to three types of messages: 

System generated messages
System-generated messages report events that occur in the mbedlet environment. For example, when the user presses a key or clicks on a mouse key, a system-generated message occurs.
Base player messages
Base players, such as Text, Sprite, Button, Picture, and Sound have internally defined built-in messages. For example, several of these players can respond to the Play message.
User-defined messages
You can define messages for a handler. For example, to create an mbedlet that animates a cow jumping over a fence, you could define a Jump handler and a Jump message that would trigger the handler.

When a player receives a message, it checks to see whether it has a handler for that message. If there is no handler for the message, it does nothing. If there is a handler for the message, the player checks to see whether it must evaluate any conditions before taking action.

A simple handler might describe the actions to take when a user presses a button. To create this type of handler:

  1. Highlight the button in the Players window and click the Handlers button.
  2. Click on the New Handler button.
    By default, the MOUSEDOWN message appears.
  3. Right click on MOUSEDOWN.
    A menu pops up, showing all of the messages that can be sent to this button.
  4. Choose MOUSEUP.
    Now the button knows it is waiting for the MOUSEUP message, but still doesn't know what to do when it gets the message.
  5. Click on the Insert Line button.
    The next line of the handler appears, so you can enter an action. The default values are ME, SHOW.
  6. To have the button play a path, right-click on ME and change it to the name of your path, then right-click on SHOW and change it to PLAY.



Previous Page Next Page