Kickstart

The method you might use most often is ru.hwl.svetka.Evaluator#evaluate(expression : String). Evaluator instances must be initialized in a special way, so you must not call Evaluator’s constructor explicitly. To retrieve an instance invoke ru.hwl.svetka.EvaluatorPool#newEvaluator(evaluatorName : String) factory method. EvaluatorPool is singleton.
import ru.hwl.svetka.Evaluator;
import ru.hwl.svetka.EvaluatorPool;
...
var pool : EvaluatorPool = EvaluatorPool.instance();
var evl : Evaluator = pool.newEvaluator("evl");
var result = evl.evaluate("2+2"); // result is 4
Note that “2+2” is evaluated by browser’s JS-engine. To access variables and objects existing on the AS-side you have to expose them to the JS-engine using ru.hwl.svetka.Evaluator#expose(objectToExpose : Object, objectAliasOnJsSide : String) method:
var obj : SomeTestObject = new SomeTestObject();
evl.expose(obj, "obj");
result = evl.evaluate("obj.doSomething(1, 2, 3)"); // SomeTestObject#doSomething(int, int, int) is
   // invoked on the AS-side and the result is stored in "result" var
You can assign a number of aliases to one variable:
evl.expose(obj, "anotherAliasForObj");
evl.expose(obj, "yetAnotherAlias");
result = evl.evaluate("anotherAliasForObj == yetAnotherAlias") &&
   evl.evaluate("yetAnotherAlias") == obj; // result is true

Now when you’ve learnt several basic use cases, it’s time to learn how to get Svetka and how to make it working.



Copyright © 2006–2008 by Assembla, LLC / Phone 1.781.328.2241 / E-mail: info@assembla.com