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:
- Associate the handler with the mbedlet or with a particular player.
- Specify the message that causes the handler to execute.
- Specify a condition that determines whether to execute the handler.
- Define the players that the handler activates and the actions that
they take.
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.
- If there are no conditions, the handler executes.
- If there are conditions, the handler evaluates them before executing.

A simple handler might describe the actions to take when a user presses
a button. To create this type of handler:
- Highlight the button in the Players window and click the Handlers button.
- Click on the New Handler button.
By default, the MOUSEDOWN message appears.
- Right click on MOUSEDOWN.
A menu pops up, showing all of the messages that can be sent to this button.
- 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.
- 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.
- 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