From 0ecb81226613ac2b1657a16a76c8f10be0b959ae Mon Sep 17 00:00:00 2001 From: Skyler Lehmkuhl Date: Tue, 1 Jan 2013 17:55:18 -0500 Subject: [PATCH] HTML5 working again --- base.js | 82 +++++++++++++++++++++++++++++++++++++++++++--- lightningbeam.py | 18 ++++++++-- svlgui.py | 6 ++-- swfc/swfc_linux64 | Bin 1174914 -> 1180840 bytes 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/base.js b/base.js index 6a76ed5..801c6d1 100644 --- a/base.js +++ b/base.js @@ -13,7 +13,8 @@ var appendError = function(str){ } function log(str){ - setTimeout("appendError('"+str+"')", 1) + // setTimeout("appendError('"+str+"')", 1) + console.log(str) } function trace(str) { @@ -21,6 +22,29 @@ function trace(str) { log(str); } +Object.defineProperty(Object.prototype, '_makeNonEnumerable', { + value: function() { + var propertyName; + var propertyDescriptor; + + for (var i in this) { + propertyName = i; + propertyDescriptor = Object.getOwnPropertyDescriptor(this, propertyName); + propertyDescriptor.enumerable = false; + Object.defineProperty(this, propertyName, propertyDescriptor); + } + }, + enumerable : false, + configurable : true, +}); + +function makeNonEnumerable(cls) { + obj = cls() + for (i in obj) { + Object.defineProperty(obj.prototype, i, {value:obj[i], enumerable:false}); + } +} + function _timerBase () { /* This provides the 'tick' by which all animations are run. Playing animations should have their ._draw() method added here; @@ -125,10 +149,27 @@ function getObjectClass(obj) { function Frame () { this.actions = '' + this._x = 0 + this._y = 0 + this._rotation = 0 + this._xscale = 1 + this._yscale = 1 this.run_script = function() { eval(this.actions) } + this._makeNonEnumerable() } +// makeNonEnumerable(Frame) +// Object.defineProperty(Frame.prototype, "actions", {enumerable: false, value: ''}) +// Object.defineProperty(Frame.prototype, "_x", {enumerable: false, value: 0}) +// Object.defineProperty(Frame.prototype, "_y", {enumerable: false, value: 0}) +// Object.defineProperty(Frame.prototype, "_rotation", {enumerable: false, value: 0}) +// Object.defineProperty(Frame.prototype, "_xscale", {enumerable: false, value: 1}) +// Object.defineProperty(Frame.prototype, "_yscale", {enumerable: false, value: 1}) +// Object.defineProperty(Frame.prototype, "run_script", {enumerable: false, value: function () { +// eval(this.actions) +// } +// }) function MovieClip() { /* From the ActionScript reference: @@ -145,11 +186,14 @@ function MovieClip() { */ this._layers = [new Layer(this)] this._currentframe = 1; + this._previousframe = undefined this._playing = true; this._x = 0; this._y = 0; this._xscale = 1; this._yscale = 1; + this._xmouse = undefined; + this._ymouse = undefined; this._rotation = 0; this._visible = true; this._id = "MC"+Math.round(Math.random()*1000000000000) @@ -245,6 +289,7 @@ function MovieClip() { cr.restore() this._previousframe = this._currentframe if (!frame2) { + // alert(5) frame._x = this._x frame._y = this._y frame._xscale = this._xscale @@ -325,7 +370,9 @@ function MovieClip() { } this.onUnload = function () { //No } + this._makeNonEnumerable() } +// makeNonEnumerable(MovieClip); function Layer (parent) { this._frames = [new Frame()] @@ -350,11 +397,31 @@ function Layer (parent) { } } else { - if (this._frames[currentframe-1][i]) { - this._parent[i]._draw(this._frames[currentframe-1][i]); - } + this._parent[i]._draw(this._frames[currentframe-1][i]) } } + // for (var i in this._parent) { + // if (this._frames[currentframe-1]==undefined) { + // for (var j=0; jcurrentframe-1; j--) { + // if (this._frames[j]) { + // next = j + // } + // } + // if (this._frames[last][i]) { + // this._parent[i]._draw(this._frames[last][i],this._frames[next][i],(currentframe-last)/(next-last)); + // } + // } + // else { + // if (this._frames[currentframe-1][i]) { + // this._parent[i]._draw(this._frames[currentframe-1][i]); + // } + // } + // } if (this._frames[currentframe-1]) { if (this._parent._playing) { this._frames[currentframe-1].run_script() @@ -368,7 +435,9 @@ function Layer (parent) { this.play = function () { this._parent.play() } + this._makeNonEnumerable() } +// makeNonEnumerable(Layer); function Shape() { // Not part of the ActionScript spec, but necessary. @@ -451,6 +520,7 @@ function Shape() { cr.beginPath() } } +// makeNonEnumerable(Shape); function TextField() { /*From the ActionScript reference: @@ -591,6 +661,7 @@ function TextField() { } } +makeNonEnumerable(TextField); var _rootFrame = new Frame() var _root = new MovieClip() @@ -598,6 +669,9 @@ var _root = new MovieClip() _rootFrame._root = {} _rootFrame._root._x = 50 _rootFrame._root._y = 40 +_rootFrame._root._xscale = 1 +_rootFrame._root._yscale = 1 +_rootFrame._root._rotation = 0 /*if (canvas.getContext) { cr = canvas.getContext("2d"); diff --git a/lightningbeam.py b/lightningbeam.py index ead1f57..af9afda 100755 --- a/lightningbeam.py +++ b/lightningbeam.py @@ -221,7 +221,18 @@ def run_file(self=None): open(os.getenv('HOME')+"/test.sc", "w").write(create_sc(root)) svlgui.execute("swfc/swfc_"+svlgui.PLATFORM+" "+os.getenv('HOME')+"/test.sc -o "+os.getenv('HOME')+"/test.swf") #TODO: Make this cross-platform compatible - logloc = os.getenv('HOME')+"/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt" + if svlgui.PLATFORM=="win32": + # Untested. + logloc = os.getenv('HOME')+"\\AppData\\Roaming\\Macromedia\\Flash Player\\Logs\\flashlog.txt" + elif "linux" in svlgui.PLATFORM: + if not os.path.exists(os.getenv('HOME')+"/mm.cfg"): + # By default, the Flash debugger on Linux does not log traces. + # So, we create a configuration file to tell it to do so if the user hasn't already. + with open(os.getenv('HOME')+"/mm.cfg", "w") as mm: + mm.write("ErrorReportingEnable=1\nTraceOutputFileEnable=1") + logloc = os.getenv('HOME')+"/.macromedia/Flash_Player/Logs/flashlog.txt" + elif svlgui.PLATFORM=="osx": + logloc = os.getenv('HOME')+"/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt" try: logfile.close() except: @@ -236,7 +247,8 @@ def run_file(self=None): logfile = open(logloc, "r") def updatetrace(outputtext): try: - outputtext.text+=logfile.readline() + print logfile.readline() + # outputtext.text+=logfile.readline() outputtext.scroll_bottom() # this doesn't work except: pass @@ -254,7 +266,7 @@ def run_file(self=None): svlgui.execute('start '+win_flash_player_loc+" test.swf") elif svlgui.PLATFORM.startswith('linux'): linux_flash_player_loc = "" - svlgui.execute('xdg-open '+linux_flash_player_loc+" test.swf") + svlgui.execute("xdg-open "+linux_flash_player_loc+" "+os.getenv('HOME')+"/test.swf") def create_html5(root): retval = "\n\