O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required