3D Lingo Dictionary > O-S > sendEvent |  |

sendEvent

Syntax

    member(whichCastmember).sendEvent(#eventName, arg1, arg2,...)

Description

3D command; sends the event `eventName,` and an arbitrary number of arguments (`arg1, arg2, ...`) to all scripts registered to receive the event. Use `registerScript()`, `registerForEvent()`, or `setCollisionCallback()` to register scripts for events.

Example

The first line creates an instance of a parent script named "tester". The second line sets the handler of the script instance, jumpPluto, as the handler to be called when the `#jump` event is sent. The third line registers a movie script handler named jumpMars as another handler to be called when the `#jump` event is sent. The fourth line sends the `#jump` event. The handlers `#jumpMars` in a movie script and `#jumpPluto` are called, along with any other handlers registered for the `#jump` event. Note that a script instance value of 0 indicates that you are registering a handler of a movie script, as opposed to a handler of a behavior instance or of a child of a parent script.

    t = new (script "tester")
    member("scene").registerForEvent(#jump, #jumpPluto, t)
    member("scene").registerForEvent(#jump, #jumpMars, 0)
    member("scene").sendEvent(#jump)

See also

`registerScript()`, `registerForEvent()`, `setCollisionCallback()`