Last active
December 18, 2015 05:09
-
-
Save AxGord/5730835 to your computer and use it in GitHub Desktop.
HScript live coding. Using in https://github.com/AxGord/LiveTeacher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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