Mouse Tasks

Table 9-7 shows the handler(s) and scripts(s) used to accomplish common tasks related to the mouse. The trick is to place the correct type of handler in the correct type of script, so that it will be called when the event of interest occurs. For the purposes of this table, I’ve made up the following short-hand notations:

  • "Mouse click handlers" include on mouseDown, on mouseUp, on rightMouseUp, on rightMouseDown, and on mouseUpOutside.

  • "Mouse rollover handlers" include on mouseEnter, on mouseLeave, and on mouseWithin (new in D6). In D5 use the rollover() function or the rollover property instead).

  • "Frame handlers" include on exitFrame, on enterFrame, on idle, and on prepareFrame.

Note that the effect of these handlers depends on the script in which they are placed.

Table 9-7. Common Mouse Tasks

To Detect This Event or System Property:

Use This Type of Handler, Property or Function:

In This Type of Script:

Mouse clicks on all sprites using a particular cast member

Mouse click handler

Cast member script

Mouse clicks on a sprite

Mouse click handler

Sprite script

Mouse clicks ignored by all sprites in a frame

Mouse click handler

Frame script

Mouse clicks throughout the entire movie otherwise ignored by other scripts

Mouse click handler

Movie script

All left mouse clicks before they are passed to individual sprites

the mouseDownScript or the mouseUpScript

Movie script

Rollovers on all sprites using a particular cast member

Mouse rollover handler

Cast member ...

Get Lingo in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.