From 7ae4e717b3641ab02feac2efc8f599b199189211 Mon Sep 17 00:00:00 2001 From: Matt Karl Date: Thu, 30 Jul 2015 13:04:12 -0400 Subject: [PATCH] Updated postPublish to check for failed publish --- package.json | 2 +- .../Optimizing/Optimize Graphics.jsfl | 4 ++ .../Optimizing/Optimize Keyframes.jsfl | 12 +++-- src/Tools/HTMLCanvasPostPublish.jsfl | 53 +++++++++++++++---- src/io.springroll.toolkit.mxi | 2 +- 5 files changed, 56 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index aba6379..d312996 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.0.2", + "version": "1.0.3", "private": true, "devDependencies": { "grunt": "^0.4.5", diff --git a/src/Commands/Optimizing/Optimize Graphics.jsfl b/src/Commands/Optimizing/Optimize Graphics.jsfl index 8348888..870ce5f 100755 --- a/src/Commands/Optimizing/Optimize Graphics.jsfl +++ b/src/Commands/Optimizing/Optimize Graphics.jsfl @@ -82,6 +82,8 @@ return; } + fl.showIdleMessage(false); + // Clear the output window fl.outputPanel.clear(); fl.trace("+------------------------------------------+"); @@ -120,6 +122,8 @@ } var sec = Math.round((microtime() - now) * 1000) / 1000; fl.trace("\nFinished optimizing in " + sec + " sec"); + + fl.showIdleMessage(true); }; /** diff --git a/src/Commands/Optimizing/Optimize Keyframes.jsfl b/src/Commands/Optimizing/Optimize Keyframes.jsfl index 64d735e..bc67962 100644 --- a/src/Commands/Optimizing/Optimize Keyframes.jsfl +++ b/src/Commands/Optimizing/Optimize Keyframes.jsfl @@ -12,6 +12,8 @@ var OptimizeKeyframes = function() { if (!this.getDOM()) return; + + fl.showIdleMessage(false); // Get the saved checks var settingsPath = 'Commands/Optimizing/OptimizeKeyframes.json'; @@ -59,13 +61,15 @@ // get the current timeline this.preprocess(this.dom.getTimeline()); + + fl.showIdleMessage(true); }; // Reference to the prototype var p = OptimizeKeyframes.prototype = new Command(); /** - * First, a preprocess task will remove any tween where the keyframes + * First, a preprocess task will remove any tween where the keyframes * are the same, this will help eliminate more cases where tweens * would typically block the optimizing of keyframes * @method preprocess @@ -115,7 +119,7 @@ lastKeyframe = frame; // go to the next keyframe - j += frame.duration; + j += frame.duration; } // Clear the keyframe for each layer @@ -160,7 +164,7 @@ } // go to the next keyframe - j += frame.duration; + j += frame.duration; } // Clear the keyframe for each layer @@ -183,7 +187,7 @@ return false; } - // Loop through all the elements, they should + // Loop through all the elements, they should // be in the same layered order to be considered the same // so we'll compare an element in the last keyframe // and a keyframe in the current keyframe diff --git a/src/Tools/HTMLCanvasPostPublish.jsfl b/src/Tools/HTMLCanvasPostPublish.jsfl index 0178002..447e49c 100644 --- a/src/Tools/HTMLCanvasPostPublish.jsfl +++ b/src/Tools/HTMLCanvasPostPublish.jsfl @@ -1,8 +1,15 @@ -(function() +(function(window) { fl.addEventListener("postPublish", onPostPublish); function onPostPublish() + { + fl.showIdleMessage(false); + postPublish(); + fl.showIdleMessage(true); + } + + function postPublish() { // Get the current document var dom = fl.getDocumentDOM(); @@ -38,6 +45,30 @@ if (!FLfile.exists(file)) return; var content = FLfile.read(file); + + try + { + var empty = function(){}; + + var createjs = { + Container: empty, + Bitmap: empty, + MovieClip: empty, + Shape: empty, + Sprite: empty, + Tween: empty, + Rectangle: empty, + Ease: empty + }; + + eval(content); // jshint ignore:line + } + catch(e) + { + fl.trace("error: " + e.message); + alert("File was published improperly. Please quit Flash and try publishing again."); + return; + } // Extract the properties var regex = new RegExp("properties = [^;]+;", "gm"); @@ -81,7 +112,7 @@ id = matches[i].substr(5).replace(" =", ''); libContent = "\n\tvar " + id + ";" + libContent; libContent = libContent.replace( - new RegExp("this\." + id + "([\.\,\)\}\;])", "g"), + new RegExp("this\." + id + "([\.\,\)\}\;])", "g"), id + "$1" ); } @@ -169,26 +200,26 @@ function stringify(obj) { var t = typeof (obj); - if (t != "object" || obj === null) + if (t != "object" || obj === null) { // simple data type if (t == "string") obj = '"' + obj + '"'; return String(obj); - } - else + } + else { // recurse array or object var n, v, json = [], arr = (obj && obj.constructor == Array); - for (n in obj) + for (n in obj) { v = obj[n]; t = typeof(v); - if (obj.hasOwnProperty(n)) + if (obj.hasOwnProperty(n)) { - if (t == "string") - v = '"' + v + '"'; - else if (t == "object" && v !== null) + if (t == "string") + v = '"' + v + '"'; + else if (t == "object" && v !== null) v = stringify(v); json.push((arr ? "" : '"' + n + '":') + String(v)); } @@ -197,4 +228,4 @@ } } -}()); \ No newline at end of file +}(window)); \ No newline at end of file diff --git a/src/io.springroll.toolkit.mxi b/src/io.springroll.toolkit.mxi index f81e289..aae7bc6 100644 --- a/src/io.springroll.toolkit.mxi +++ b/src/io.springroll.toolkit.mxi @@ -3,7 +3,7 @@ name="SpringRoll Flash Toolkit" id="io.springroll.toolkit" requires-restart="true" - version="1.0.2"> + version="1.0.3">