Skip to content

Commit

Permalink
* Timeline now export frames correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bchevalier committed Jul 17, 2015
1 parent 094ba17 commit 84c2648
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 34 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release history

## v0.1.9
Fixed export of drawings that last several frames

## v0.1.8
Fixed badly handled case when only one frame has to be prerendered and exported into an atlas

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For use as an api:

## Use
Command line:
`jeff -src mySwf.swf`
`jeff -s mySwf.swf`

API:
```
Expand Down
6 changes: 4 additions & 2 deletions lib/Gordon/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ SwfParser.prototype = {
var timeline = [];
var sprite = {
type: 'sprite',
frameCount: frameCount, //maybe useless since it is equal to timeline.length
frameCount: frameCount,
id: id,
timeline: timeline
};
Expand All @@ -195,7 +195,9 @@ SwfParser.prototype = {
else { this._handleUnhandledTag(handle, code, stream, stream.offset, len, frm); }
if (this.aborting) return null;
}while (code);
if (numTags > 0) timeline.push(frm);
if (code !== 0) {
timeline.push(frm);
}
}while (code);
this.onData(sprite);
this._dictionary[id] = sprite;
Expand Down
63 changes: 33 additions & 30 deletions lib/SwfObjectProcessor/generateChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,47 +234,50 @@ function generateChildren(symbol, symbols) {
var depths = {}; // Contains element mapped by depth
var depth, d, depthArray, nDepths;
var timeline = symbol.swfObject.timeline;
var duration = timeline.length;
// var duration = timeline.length;
var duration = symbol.duration;
for (f = 0; f < duration; f += 1) {

var displayList = timeline[f].displayList;
var morphedShapeReplacements = [];
for (d = 0, depthArray = Object.keys(displayList), nDepths = depthArray.length; d < nDepths; d += 1) {
depth = depthArray[d];
objectData = displayList[depth];
if (objectData === null) {
objectLayerData[depth] = null;
continue;
}
if (timeline[f] !== undefined) {
var displayList = timeline[f].displayList;
var morphedShapeReplacements = [];
for (d = 0, depthArray = Object.keys(displayList), nDepths = depthArray.length; d < nDepths; d += 1) {
depth = depthArray[d];
objectData = displayList[depth];
if (objectData === null) {
objectLayerData[depth] = null;
continue;
}

// objects are not redefined every frame
// In objectData, if an object remains unchanged from a frame A to a frame B then it does not appear in frame B
if (!objectLayerData[depth]) {
// objects are not redefined every frame
// In objectData, if an object remains unchanged from a frame A to a frame B then it does not appear in frame B
if (!objectLayerData[depth]) {

// no object was previously defined for the given depth
objectLayerData[depth] = objectData;
} else {
// no object was previously defined for the given depth
objectLayerData[depth] = objectData;
} else {

for (var a = 0, attributeArray = Object.keys(objectData), nAttributes = attributeArray.length; a < nAttributes; a += 1) {
var attribute = attributeArray[a];
for (var a = 0, attributeArray = Object.keys(objectData), nAttributes = attributeArray.length; a < nAttributes; a += 1) {
var attribute = attributeArray[a];

// the object attribute has changed
objectLayerData[depth][attribute] = objectData[attribute];
// the object attribute has changed
objectLayerData[depth][attribute] = objectData[attribute];
}
}
}

// Testing for special case when object is a morphing
objectData = objectLayerData[depth];
var childSymbol = symbols[objectData.id];
// Testing for special case when object is a morphing
objectData = objectLayerData[depth];
var childSymbol = symbols[objectData.id];

if (childSymbol && childSymbol.isMorphing) {
var ratio = objectData.ratio || 0;
if (childSymbol && childSymbol.isMorphing) {
var ratio = objectData.ratio || 0;

// Creating a new graphic that correspond to interpolation of the morphing with respect to the given ratio
var morphedShapeId = createMorphedShape(symbols, childSymbol, symbols[objectData.id].swfObject, ratio);
// Creating a new graphic that correspond to interpolation of the morphing with respect to the given ratio
var morphedShapeId = createMorphedShape(symbols, childSymbol, symbols[objectData.id].swfObject, ratio);

// Replacing symbol id
morphedShapeReplacements.push({ depth: depth, morphId: morphedShapeId, originalId: childSymbol.id });
// Replacing symbol id
morphedShapeReplacements.push({ depth: depth, morphId: morphedShapeId, originalId: childSymbol.id });
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jeff",
"description": "Extracts Json meta-data and images from a SWF Flash file.",
"version": "0.1.8",
"version": "0.1.9",
"private": false,
"author": {
"name": "Brice Chevalier",
Expand Down

0 comments on commit 84c2648

Please sign in to comment.