Grimace for Developers and Researchers

Events

Grimace can notify about certain events. In order to be notified, event listeners need to be registered.

An event listener is registered through the addEventListener() method and deleted through the removeEventListener() method.

In ActionScript 3 environments, these methods are accessed via the events property of the Grimace instance.

The demo files for the various platforms show all available events in use.

Available events

loadComplete

Facedata is loaded by the loadFacedata() method, which accepts an array of relative or absolute URLs to the Facedata XML files.

When all files have completed loading and Grimace is ready to display the face, this event is triggered. This is the time to resize and position the face and then call the draw() method.

emotionSet

Whenever the displayed emotion has changed, this event is triggered. If the new emotion was set with fadeTime > 0, the event is triggered when the animation is complete.

The event does not include the new emotion state. Use the getEmotion() method in the event handler instead.

captureComplete

SWF files are not allowed to write files. To capture a screenshot of the currently displayed face, the file needs to be handled by a server-side script. A sample script (SaveFile.php) is being used by the demos and is included in the distribution.

The location of the server-side script is set via the setCaptureUrl() method. The capture() method sends the captured screenshot to the script.

When the upload is complete, the script returns the absolute URL of the uploaded image. This string is retrieved by Grimace and passed on to the embedding environment as the url property of the captureComplete event object.