Last active
December 30, 2015 21:09
-
-
Save dpeek/7885802 to your computer and use it in GitHub Desktop.
hscript callbacks
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
| // compile with: | |
| // haxe -main Test -swf test.swf -lib hscript | |
| class Test extends flash.display.Sprite | |
| { | |
| static function main() flash.Lib.current.addChild(new Test()); | |
| function new() | |
| { | |
| super(); | |
| // draw something to click | |
| graphics.beginFill(0xFF, 1); | |
| graphics.drawRect(0, 0, 100, 100); | |
| // this is your users script | |
| var script = "function(e) { trace('do something'); })"; | |
| // parse your user script | |
| var parser = new hscript.Parser(); | |
| var ast = parser.parseString(script); | |
| var interp = new hscript.Interp(); | |
| var callback = interp.execute(ast); | |
| addEventListener(flash.events.MouseEvent.CLICK, callback); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment