Lingo Dictionary > A-C > clickOn |  |

clickOn

Syntax

    the clickOn

Description

Function; returns the last active sprite clicked by the user. An active sprite is a sprite that has a sprite or cast member script associated with it.

When the user clicks the Stage, `clickOn` returns 0. To detect whether the user clicks a sprite with no script, you must assign a placeholder script to it (`"--`,`"` for example) so that it can be detected by the `clickOn` function.

The `clickOn` can be checked within a repeat loop. However, neither `clickOn` nor `clickLoc` functions change value when the handler is running. The value that you obtain is the value from before the handler started.

Example

This statement checks whether sprite 7 was the last active sprite clicked:

    if the clickOn = 7 then alert "Sorry, try again."

Example

This statement sets the`foreColor` property of the last active sprite that was clicked to a random color:

    sprite(the clickOn).foreColor = random(255)-1

See also

`doubleClick`, `the mouseDown (system property)`, `mouseMember`, `the mouseUp (system property)`