Skip to content

Commit

Permalink
Updated postPublish to check for failed publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Karl committed Jul 30, 2015
1 parent 9f63090 commit 7ae4e71
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.2",
"version": "1.0.3",
"private": true,
"devDependencies": {
"grunt": "^0.4.5",
Expand Down
4 changes: 4 additions & 0 deletions src/Commands/Optimizing/Optimize Graphics.jsfl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
return;
}

fl.showIdleMessage(false);

// Clear the output window
fl.outputPanel.clear();
fl.trace("+------------------------------------------+");
Expand Down Expand Up @@ -120,6 +122,8 @@
}
var sec = Math.round((microtime() - now) * 1000) / 1000;
fl.trace("\nFinished optimizing in " + sec + " sec");

fl.showIdleMessage(true);
};

/**
Expand Down
12 changes: 8 additions & 4 deletions src/Commands/Optimizing/Optimize Keyframes.jsfl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
var OptimizeKeyframes = function()
{
if (!this.getDOM()) return;

fl.showIdleMessage(false);

// Get the saved checks
var settingsPath = 'Commands/Optimizing/OptimizeKeyframes.json';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -115,7 +119,7 @@
lastKeyframe = frame;

// go to the next keyframe
j += frame.duration;
j += frame.duration;
}

// Clear the keyframe for each layer
Expand Down Expand Up @@ -160,7 +164,7 @@
}

// go to the next keyframe
j += frame.duration;
j += frame.duration;
}

// Clear the keyframe for each layer
Expand All @@ -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
Expand Down
53 changes: 42 additions & 11 deletions src/Tools/HTMLCanvasPostPublish.jsfl
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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"
);
}
Expand Down Expand Up @@ -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));
}
Expand All @@ -197,4 +228,4 @@
}
}

}());
}(window));
2 changes: 1 addition & 1 deletion src/io.springroll.toolkit.mxi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name="SpringRoll Flash Toolkit"
id="io.springroll.toolkit"
requires-restart="true"
version="1.0.2">
version="1.0.3">
<author name="SpringRoll"/>
<description>
<![CDATA[Commands for Exporting, Optimizing and Publish HTML5 Canvas documents]]>
Expand Down

0 comments on commit 7ae4e71

Please sign in to comment.