About the Project

Svetka is eval for ActionScript 3. It uses browser’s Javascript. ActionScript 3 doesn’t have eval function. Nor do previous versions of AS – they have function named “eval” with rather different semantics. The simplest way to evaluate a string is to pass a computation to browser’s JS engine. Since AS 3 it can be done using ExternalInterface class:

import flash.external.ExternalInterface;
...
result = ExternalInterface.call("eval", expression);

The problem is we can not access AS runtime variables and objects within ExternalInterface.call. Primitive typed variables are perfectly passed through the AS/JS interface, but say variables of Function type can not be passed. Thus objects’ methods can not be passed either. The solution is to create objects on-the-fly on the JS-side with stub methods calling corresponding methods on the AS-side.

This what is done with Svetka. Sounds quite simple, but a number of design problems has been carefully solved during the development.

“Great! That’s what I need!”

To learn how to use Svetka, first read Kickstart page.

Licensing

Svetka is distributed under the terms of Apache License 2.0.

Competitors

Since I’ve found D.eval I’ve been feeling I’m reinventing the wheel. But my solution seems to be more lightweight, browser-oriented and already supports exception handling while D.eval does not. And most important that mine is open source :-)

No comments yet. post a comment >