Grimace can notify about certain events. In order to be notified, event listeners need to be registered.
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.
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
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.
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.
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.