Skip to content

Instantly share code, notes, and snippets.

@AxGord
Last active December 18, 2015 05:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AxGord/5730835 to your computer and use it in GitHub Desktop.
Save AxGord/5730835 to your computer and use it in GitHub Desktop.
HScript live coding. Using in https://github.com/AxGord/LiveTeacher
package ;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.Lib;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.Event;
/**
* ...
* @author AxGord
*/
class Main
{
static function main()
{
var stage = Lib.current.stage;
var input:TextField = new TextField();
input.width = stage.stageWidth / 2;
input.height = stage.stageHeight;
input.x = input.y = 0;
var output:TextField = new TextField();
output.width = stage.stageWidth / 2;
output.height = stage.stageHeight;
output.x = stage.stageWidth / 2;
output.y = 0;
Lib.current.addChild(input);
Lib.current.addChild(output);
input.border = true;
input.borderColor = 0x000000;
input.background = true;
input.backgroundColor = 0x999999;
input.type = TextFieldType.INPUT;
input.multiline = true;
var parser = new hscript.Parser();
input.addEventListener(Event.CHANGE, function(_) {
try {
var program = parser.parseString(input.text);
var interp = new hscript.Interp();
output.text = interp.execute(program);
} catch (e:Dynamic) { };
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment