HTML5 working again

This commit is contained in:
Skyler Lehmkuhl 2013-01-01 17:55:18 -05:00
parent bdefa2680f
commit 0ecb812266
4 changed files with 96 additions and 10 deletions

82
base.js
View File

@ -13,7 +13,8 @@ var appendError = function(str){
} }
function log(str){ function log(str){
setTimeout("appendError('"+str+"')", 1) // setTimeout("appendError('"+str+"')", 1)
console.log(str)
} }
function trace(str) { function trace(str) {
@ -21,6 +22,29 @@ function trace(str) {
log(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 () { function _timerBase () {
/* This provides the 'tick' by which all animations are run. /* This provides the 'tick' by which all animations are run.
Playing animations should have their ._draw() method added here; Playing animations should have their ._draw() method added here;
@ -125,10 +149,27 @@ function getObjectClass(obj) {
function Frame () { function Frame () {
this.actions = '' this.actions = ''
this._x = 0
this._y = 0
this._rotation = 0
this._xscale = 1
this._yscale = 1
this.run_script = function() { this.run_script = function() {
eval(this.actions) 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() { function MovieClip() {
/* From the ActionScript reference: /* From the ActionScript reference:
@ -145,11 +186,14 @@ function MovieClip() {
*/ */
this._layers = [new Layer(this)] this._layers = [new Layer(this)]
this._currentframe = 1; this._currentframe = 1;
this._previousframe = undefined
this._playing = true; this._playing = true;
this._x = 0; this._x = 0;
this._y = 0; this._y = 0;
this._xscale = 1; this._xscale = 1;
this._yscale = 1; this._yscale = 1;
this._xmouse = undefined;
this._ymouse = undefined;
this._rotation = 0; this._rotation = 0;
this._visible = true; this._visible = true;
this._id = "MC"+Math.round(Math.random()*1000000000000) this._id = "MC"+Math.round(Math.random()*1000000000000)
@ -245,6 +289,7 @@ function MovieClip() {
cr.restore() cr.restore()
this._previousframe = this._currentframe this._previousframe = this._currentframe
if (!frame2) { if (!frame2) {
// alert(5)
frame._x = this._x frame._x = this._x
frame._y = this._y frame._y = this._y
frame._xscale = this._xscale frame._xscale = this._xscale
@ -325,7 +370,9 @@ function MovieClip() {
} }
this.onUnload = function () { //No this.onUnload = function () { //No
} }
this._makeNonEnumerable()
} }
// makeNonEnumerable(MovieClip);
function Layer (parent) { function Layer (parent) {
this._frames = [new Frame()] this._frames = [new Frame()]
@ -350,11 +397,31 @@ function Layer (parent) {
} }
} }
else { 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; j<currentframe-1; j++) {
// if (this._frames[j]) {
// last = j
// }
// }
// for (var j=this._frames.length; j>currentframe-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._frames[currentframe-1]) {
if (this._parent._playing) { if (this._parent._playing) {
this._frames[currentframe-1].run_script() this._frames[currentframe-1].run_script()
@ -368,7 +435,9 @@ function Layer (parent) {
this.play = function () { this.play = function () {
this._parent.play() this._parent.play()
} }
this._makeNonEnumerable()
} }
// makeNonEnumerable(Layer);
function Shape() { function Shape() {
// Not part of the ActionScript spec, but necessary. // Not part of the ActionScript spec, but necessary.
@ -451,6 +520,7 @@ function Shape() {
cr.beginPath() cr.beginPath()
} }
} }
// makeNonEnumerable(Shape);
function TextField() { function TextField() {
/*From the ActionScript reference: /*From the ActionScript reference:
@ -591,6 +661,7 @@ function TextField() {
} }
} }
makeNonEnumerable(TextField);
var _rootFrame = new Frame() var _rootFrame = new Frame()
var _root = new MovieClip() var _root = new MovieClip()
@ -598,6 +669,9 @@ var _root = new MovieClip()
_rootFrame._root = {} _rootFrame._root = {}
_rootFrame._root._x = 50 _rootFrame._root._x = 50
_rootFrame._root._y = 40 _rootFrame._root._y = 40
_rootFrame._root._xscale = 1
_rootFrame._root._yscale = 1
_rootFrame._root._rotation = 0
/*if (canvas.getContext) { /*if (canvas.getContext) {
cr = canvas.getContext("2d"); cr = canvas.getContext("2d");

View File

@ -221,6 +221,17 @@ def run_file(self=None):
open(os.getenv('HOME')+"/test.sc", "w").write(create_sc(root)) 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") svlgui.execute("swfc/swfc_"+svlgui.PLATFORM+" "+os.getenv('HOME')+"/test.sc -o "+os.getenv('HOME')+"/test.swf")
#TODO: Make this cross-platform compatible #TODO: Make this cross-platform compatible
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" logloc = os.getenv('HOME')+"/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt"
try: try:
logfile.close() logfile.close()
@ -236,7 +247,8 @@ def run_file(self=None):
logfile = open(logloc, "r") logfile = open(logloc, "r")
def updatetrace(outputtext): def updatetrace(outputtext):
try: try:
outputtext.text+=logfile.readline() print logfile.readline()
# outputtext.text+=logfile.readline()
outputtext.scroll_bottom() # this doesn't work outputtext.scroll_bottom() # this doesn't work
except: except:
pass pass
@ -254,7 +266,7 @@ def run_file(self=None):
svlgui.execute('start '+win_flash_player_loc+" test.swf") svlgui.execute('start '+win_flash_player_loc+" test.swf")
elif svlgui.PLATFORM.startswith('linux'): elif svlgui.PLATFORM.startswith('linux'):
linux_flash_player_loc = "" 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): def create_html5(root):
retval = "<head>\n\ retval = "<head>\n\
<style type=\"text/css\">\n\ <style type=\"text/css\">\n\

View File

@ -1713,7 +1713,7 @@ class Text (object):
self.width = self.font.width(self.text) self.width = self.font.width(self.text)
self.height = self.font.height self.height = self.font.height
self.iname = None self.iname = None
self.hwaccel = None self.hwaccel = False
self.type="Text" self.type="Text"
self.name = "t"+str(int(random.random()*10000))+str(SITER) self.name = "t"+str(int(random.random()*10000))+str(SITER)
self.editing = False self.editing = False
@ -2492,8 +2492,8 @@ class Group (object):
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._x = "+str(k.x)+";\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._x = "+str(k.x)+";\n"
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._y = "+str(k.y)+";\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._y = "+str(k.y)+";\n"
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._rotation = "+str(k.rot)+";\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._rotation = "+str(k.rot)+";\n"
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._xscale = "+str(k.rot)+";\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._xscale = "+str(k.xscale)+";\n"
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._yscale = "+str(k.rot)+";\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"]."+k.name+"._yscale = "+str(k.yscale)+";\n"
retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"].actions = \""+self.layers[i].frames[j].actions.replace("\n"," ").replace("\\","\\\\").replace("\"","\\\"")+"\"\n" retval += self.name+"._layers["+str(i)+"]._frames["+str(j)+"].actions = \""+self.layers[i].frames[j].actions.replace("\n"," ").replace("\\","\\\\").replace("\"","\\\"")+"\"\n"
return retval return retval

Binary file not shown.