Grimace for Developers and Researchers


Embedding in websites (JavaScript control)

Usage in HTML files is in line with general best practice of Flash embedding; an <embed> tag nested in an <object> tag. Grimace should be compatible with any browser which supports the Flash Player 9 plugin and JavaScript.

For a detailed example see the included demo in the directory js.

The demo makes use of JQuery, so this library's compatibility restrictions (Internet Explorer 6+, Firefox 3+, Safari 3+, Opera 9+) apply.

API access

All methods, including event related ones, can be directly called through the Grimace instance.

Embedding in Flash, Flex and ActionScript 3 projects

Grimace can be embedded into Flash CS4, Flex and ActionScript 3 projects. Since the component is not open source, the precompiled component Grimace.swf needs to be embedded.

It is not possible to use Grimace with Flash CS3! Though this version supports ActionScript 3, the [Embed] compiler metatag which is used to embed the component is not understood by Flash CS3.

The embedding approach is the same for all three platforms and follows this scheme:

public var grimace:*;

[Embed(source="/grimace/grimace.swf", mimeType="application/octet-stream")]
private var grimaceClass:Class;

public function Embed() {
var grimaceBytes:ByteArray = (new grimaceClass() as ByteArray);
var ldr:Loader = new Loader();
ldr.loadBytes(grimaceBytes, new LoaderContext(false, ApplicationDomain.currentDomain));
var scope:* = this;
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function():void {

public function init(grimace:*):void {
this.grimace = grimace;

// now you can access all API methods

API access

Accessed via ActionScript 3, the API is split across two properties of the Grimace instance.

In the above example (instance named grimace), you would call and grimace.api.loadFacedata.