diff --git a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
index 9027644dc..9bbb9d5ef 100644
--- a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
+++ b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
@@ -148,7 +148,7 @@ public class CommandLineArgumentParser {
System.out.println("java -jar ffdec.jar -export script \"C:\\decompiled\" myfile.swf -selectas3class com.example.MyClass com.example.SecondClass");
System.out.println("java -jar ffdec.jar -format script:pcode -export script \"C:\\decompiled\" myfile.swf");
System.out.println("java -jar ffdec.jar -format script:pcode,text:plain -export script,text,image \"C:\\decompiled\" myfile.swf");
- System.out.println("java -jar ffdec.jar -format fla:cs5.5 -export fla \"C:\\sources\" myfile.swf");
+ System.out.println("java -jar ffdec.jar -format fla:cs5.5 -export fla \"C:\\sources\\myfile.fla\" myfile.swf");
System.out.println("java -jar ffdec.jar -dumpSWF myfile.swf");
System.out.println("java -jar ffdec.jar -compress myfile.swf myfiledec.swf");
System.out.println("java -jar ffdec.jar -decompress myfiledec.swf myfile.swf");
diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java
index 4bc5a695a..55d1e442f 100644
--- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java
+++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java
@@ -1,16 +1,16 @@
/*
* Copyright (C) 2010-2014 PEXS
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -143,7 +143,7 @@ public class XFLConverter {
public static final int KEY_MODE_SHAPE_TWEEN = 17922;
public static final int KEY_MODE_MOTION_TWEEN = 8195;
public static final int KEY_MODE_SHAPE_LAYERS = 8192;
-
+
private XFLConverter() {
}
@@ -726,7 +726,7 @@ public class XFLConverter {
}
private static List getOneInstanceShapes(List tags, HashMap characters) {
- if (true) { //the feature was removed due to multiple layers in some shapes
+ if (true) { //the feature was removed due to multiple layers in some shapes
return new ArrayList<>();
}
HashMap usages = new HashMap<>();
@@ -1013,7 +1013,7 @@ public class XFLConverter {
if (cacheAsBitmap) {
ret += " cacheAsBitmap=\"true\"";
}
- if (!isVisible && flaVersion.ordinal()>=FLAVersion.CS5_5.ordinal()) {
+ if (!isVisible && flaVersion.ordinal() >= FLAVersion.CS5_5.ordinal()) {
ret += " isVisible=\"false\"";
}
ret += ">";
@@ -1107,7 +1107,7 @@ public class XFLConverter {
return new Date().getTime() / 1000;
}
- public static String convertLibrary(SWF swf, Map characterVariables, Map characterClasses, List oneInstanceShapes, String backgroundColor, List tags, HashMap characters, HashMap files, HashMap datfiles,FLAVersion flaVersion) {
+ public static String convertLibrary(SWF swf, Map characterVariables, Map characterClasses, List oneInstanceShapes, String backgroundColor, List tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion) {
//TODO: Imported assets
//linkageImportForRS="true" linkageIdentifier="xxx" linkageURL="yyy.swf"
@@ -1211,7 +1211,7 @@ public class XFLConverter {
} else if (character instanceof DefineVideoStreamTag) {
recCharStr = convertVideoInstance(null, matrix, (DefineVideoStreamTag) character, null);
} else {
- recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags,flaVersion);
+ recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags, flaVersion);
}
int duration = frame - lastFrame;
lastFrame = frame;
@@ -1248,7 +1248,7 @@ public class XFLConverter {
if (sprite.subTags.isEmpty()) { //probably AS2 class
continue;
}
- symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterId(),flaVersion);
+ symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterId(), flaVersion, files);
} else if (symbol instanceof ShapeTag) {
itemIcon = "1";
ShapeTag shape = (ShapeTag) symbol;
@@ -1269,11 +1269,11 @@ public class XFLConverter {
symbLinkStr += " itemIcon=\"" + itemIcon + "\"";
}
symbLinkStr += " loadImmediate=\"false\"";
- if(flaVersion.ordinal()>=FLAVersion.CS5_5.ordinal()) {
+ if (flaVersion.ordinal() >= FLAVersion.CS5_5.ordinal()) {
symbLinkStr += " lastModified=\"" + getTimestamp() + "\"";
//TODO: itemID=\"518de416-00000341\"
}
- symbLinkStr += "/>";
+ symbLinkStr += "/>";
symbols.add(symbLinkStr);
} else if (symbol instanceof ImageTag) {
ImageTag imageTag = (ImageTag) symbol;
@@ -1485,7 +1485,7 @@ public class XFLConverter {
}
String symbolFile = "movie" + symbol.getCharacterId() + "." + "flv";
String mediaLinkStr = "";
- if (data.length == 0) { //Video has zero length, this probably means it is "Video - Actionscript-controlled"
+ if (data.length == 0) { //Video has zero length, this probably means it is "Video - Actionscript-controlled"
long ts = getTimestamp();
String datFileName = "M " + (datfiles.size() + 1) + " " + ts + ".dat";
mediaLinkStr = "";
@@ -1564,7 +1564,7 @@ public class XFLConverter {
}
}
- private static String convertFrame(boolean shapeTween, HashMap characters, List tags, SoundStreamHeadTypeTag soundStreamHead, StartSoundTag startSound, int frame, int duration, String actionScript, String elements) {
+ private static String convertFrame(boolean shapeTween, HashMap characters, List tags, SoundStreamHeadTypeTag soundStreamHead, StartSoundTag startSound, int frame, int duration, String actionScript, String elements, HashMap files) {
String ret = "";
DefineSoundTag sound = null;
if (startSound != null) {
@@ -1590,14 +1590,16 @@ public class XFLConverter {
}
String soundEnvelopeStr = "";
if (soundStreamHead != null && startSound == null) {
- ret += " soundName=\"sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat() + "\"";
+ String soundName = "sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat();
+ ret += " soundName=\"" + soundName + "\"";
ret += " soundSync=\"stream\"";
soundEnvelopeStr += "";
soundEnvelopeStr += "";
soundEnvelopeStr += "";
}
if (startSound != null && sound != null) {
- ret += " soundName=\"sound" + sound.soundId + "." + sound.getExportFormat() + "\"";
+ String soundName = "sound" + sound.soundId + "." + sound.getExportFormat();
+ ret += " soundName=\"" + soundName + "\"";
if (startSound.soundInfo.hasInPoint) {
ret += " inPoint44=\"" + startSound.soundInfo.inPoint + "\"";
}
@@ -1689,7 +1691,7 @@ public class XFLConverter {
return ret;
}
- private static String convertFrames(String prevStr, String afterStr, List oneInstanceShapes, List tags, List timelineTags, HashMap characters, int depth, FLAVersion flaVersion) {
+ private static String convertFrames(String prevStr, String afterStr, List oneInstanceShapes, List tags, List timelineTags, HashMap characters, int depth, FLAVersion flaVersion, HashMap files) {
String ret = "";
prevStr += "";
int frame = -1;
@@ -1820,14 +1822,14 @@ public class XFLConverter {
} else if (character instanceof DefineVideoStreamTag) {
elements += convertVideoInstance(instanceName, matrix, (DefineVideoStreamTag) character, clipActions);
} else {
- elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags,flaVersion);
+ elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags, flaVersion);
}
}
}
frame++;
if (!elements.equals(lastElements) && frame > 0) {
- ret += convertFrame(lastShapeTween, characters, tags, null, null, frame - duration, duration, "", lastElements);
+ ret += convertFrame(lastShapeTween, characters, tags, null, null, frame - duration, duration, "", lastElements, files);
duration = 1;
} else if (frame == 0) {
duration = 1;
@@ -1841,7 +1843,7 @@ public class XFLConverter {
}
if (!lastElements.isEmpty()) {
frame++;
- ret += convertFrame(lastShapeTween, characters, tags, null, null, (frame - duration < 0 ? 0 : frame - duration), duration, "", lastElements);
+ ret += convertFrame(lastShapeTween, characters, tags, null, null, (frame - duration < 0 ? 0 : frame - duration), duration, "", lastElements, files);
}
afterStr = "" + afterStr;
if (!ret.isEmpty()) {
@@ -1966,7 +1968,7 @@ public class XFLConverter {
return ret;
}
- public static String convertSoundLayer(int layerIndex, String backgroundColor, HashMap characters, List tags, List timeLineTags) {
+ public static String convertSoundLayer(int layerIndex, String backgroundColor, HashMap characters, List tags, List timeLineTags, HashMap files) {
String ret = "";
StartSoundTag lastStartSound = null;
SoundStreamHeadTypeTag lastSoundStreamHead = null;
@@ -1977,14 +1979,30 @@ public class XFLConverter {
for (Tag t : timeLineTags) {
if (t instanceof StartSoundTag) {
startSound = (StartSoundTag) t;
+
+ for (Tag ta : tags) {
+ if (ta instanceof DefineSoundTag) {
+ DefineSoundTag s = (DefineSoundTag) ta;
+ if (s.soundId == startSound.soundId) {
+ if (!files.containsKey("sound" + s.soundId + "." + s.getExportFormat())) { //Sound was not exported
+ startSound = null; //ignore
+ }
+ break;
+ }
+ }
+ }
+
}
if (t instanceof SoundStreamHeadTypeTag) {
soundStreamHead = (SoundStreamHeadTypeTag) t;
+ if (!files.containsKey("sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat())) { //Sound was not exported
+ soundStreamHead = null; //ignore
+ }
}
if (t instanceof ShowFrameTag) {
if (soundStreamHead != null || startSound != null) {
if (lastSoundStreamHead != null || lastStartSound != null) {
- ret += convertFrame(false, characters, tags, lastSoundStreamHead, lastStartSound, frame, duration, "", "");
+ ret += convertFrame(false, characters, tags, lastSoundStreamHead, lastStartSound, frame, duration, "", "", files);
}
frame += duration;
duration = 1;
@@ -2002,7 +2020,7 @@ public class XFLConverter {
frame = 0;
duration = 1;
}
- ret += convertFrame(false, characters, tags, lastSoundStreamHead, lastStartSound, frame, duration, "", "");
+ ret += convertFrame(false, characters, tags, lastSoundStreamHead, lastStartSound, frame, duration, "", "", files);
}
if (!ret.isEmpty()) {
ret = ""
@@ -2023,7 +2041,7 @@ public class XFLConverter {
return outlineColor.toHexRGB();
}
- public static String convertTimeline(int spriteId, List oneInstanceShapes, String backgroundColor, List tags, List timelineTags, HashMap characters, String name, FLAVersion flaVersion) {
+ public static String convertTimeline(int spriteId, List oneInstanceShapes, String backgroundColor, List tags, List timelineTags, HashMap characters, String name, FLAVersion flaVersion, HashMap files) {
String ret = "";
ret += "";
ret += "";
@@ -2046,7 +2064,7 @@ public class XFLConverter {
ret += "";
- ret += convertFrames("", "", oneInstanceShapes, tags, timelineTags, characters, po.getDepth(),flaVersion);
+ ret += convertFrames("", "", oneInstanceShapes, tags, timelineTags, characters, po.getDepth(), flaVersion, files);
ret += "";
index++;
break;
@@ -2087,7 +2105,7 @@ public class XFLConverter {
}
layerPrev += ">";
String layerAfter = "";
- String cf = convertFrames(layerPrev, layerAfter, oneInstanceShapes, tags, timelineTags, characters, d,flaVersion);
+ String cf = convertFrames(layerPrev, layerAfter, oneInstanceShapes, tags, timelineTags, characters, d, flaVersion, files);
if (cf.isEmpty()) {
index--;
}
@@ -2096,7 +2114,7 @@ public class XFLConverter {
int soundLayerIndex = layerCount;
layerCount++;
- ret += convertSoundLayer(soundLayerIndex, backgroundColor, characters, tags, timelineTags);
+ ret += convertSoundLayer(soundLayerIndex, backgroundColor, characters, tags, timelineTags, files);
ret += "";
ret += "";
return ret;
@@ -2491,8 +2509,8 @@ public class XFLConverter {
return ret;
}
- public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion flaVersion) throws IOException {
-
+ public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion flaVersion) throws IOException {
+
FileAttributesTag fa = null;
for (Tag t : swf.tags) {
if (t instanceof FileAttributesTag) {
@@ -2506,9 +2524,9 @@ public class XFLConverter {
useAS3 = fa.actionScript3;
useNetwork = fa.useNetwork;
}
-
- if(!useAS3 && flaVersion.minASVersion()>2){
- throw new IllegalArgumentException("FLA version "+flaVersion+" does not support AS1/2");
+
+ if (!useAS3 && flaVersion.minASVersion() > 2) {
+ throw new IllegalArgumentException("FLA version " + flaVersion + " does not support AS1/2");
}
File file = new File(outfile);
File outDir = file.getParentFile();
@@ -2533,7 +2551,6 @@ public class XFLConverter {
Map characterClasses = getCharacterClasses(swf.tags);
Map characterVariables = getCharacterVariables(swf.tags);
-
String backgroundColor = "#ffffff";
for (Tag t : swf.tags) {
if (t instanceof SetBackgroundColorTag) {
@@ -2541,7 +2558,7 @@ public class XFLConverter {
backgroundColor = sbc.backgroundColor.toHexRGB();
}
}
- domDocument += "";
- domDocument += convertLibrary(swf, characterVariables, characterClasses, oneInstaceShapes, backgroundColor, swf.tags, characters, files, datfiles,flaVersion);
+ domDocument += convertLibrary(swf, characterVariables, characterClasses, oneInstaceShapes, backgroundColor, swf.tags, characters, files, datfiles, flaVersion);
domDocument += "";
- domDocument += convertTimeline(0, oneInstaceShapes, backgroundColor, swf.tags, swf.tags, characters, "Scene 1",flaVersion);
+ domDocument += convertTimeline(0, oneInstaceShapes, backgroundColor, swf.tags, swf.tags, characters, "Scene 1", flaVersion, files);
domDocument += "";
domDocument += "";
domDocument = prettyFormatXML(domDocument);
@@ -2597,7 +2614,7 @@ public class XFLConverter {
}
}
- int flaSwfVersion = swf.version>flaVersion.maxSwfVersion()?flaVersion.maxSwfVersion():swf.version;
+ int flaSwfVersion = swf.version > flaVersion.maxSwfVersion() ? flaVersion.maxSwfVersion() : swf.version;
String publishSettings = "\n"
+ "\n"
+ " \n"
@@ -2609,7 +2626,7 @@ public class XFLConverter {
+ " 0\n"
+ " 0\n"
+ " 0\n"
- + (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" \n":" 0\n")
+ + (flaVersion.ordinal() >= FLAVersion.CC.ordinal() ? " \n" : " 0\n")
+ " 0\n"
+ " 0\n"
+ " 1\n"
@@ -2619,7 +2636,7 @@ public class XFLConverter {
+ " 1\n"
+ " 1\n"
+ " 1\n"
- + (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" 1\n":" 1\n")
+ + (flaVersion.ordinal() >= FLAVersion.CC.ordinal() ? " 1\n" : " 1\n")
+ " 1\n"
+ " 1\n"
+ " " + baseName + ".swf\n"
@@ -2629,7 +2646,7 @@ public class XFLConverter {
+ " " + baseName + ".gif\n"
+ " " + baseName + ".jpg\n"
+ " " + baseName + ".png\n"
- + (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" 1\n":" 1\n")
+ + (flaVersion.ordinal() >= FLAVersion.CC.ordinal() ? " 1\n" : " 1\n")
+ " " + baseName + ".smil\n"
+ " " + baseName + ".swc\n"
+ " \n"
@@ -2672,8 +2689,8 @@ public class XFLConverter {
+ " 0\n"
+ " 7\n"
+ " 0\n"
- + " "+flaSwfVersion+"\n"
- + " "+FLAVersion.swfVersionToPlayer(flaSwfVersion)+"\n"
+ + " " + flaSwfVersion + "\n"
+ + " " + FLAVersion.swfVersionToPlayer(flaSwfVersion) + "\n"
+ " " + (useAS3 ? "3" : "2") + "\n"
+ " 1\n"
+ " \n"
@@ -2703,8 +2720,7 @@ public class XFLConverter {
+ " rsl\n"
+ " wrap\n"
+ " $(AppConfig)/ActionScript 3.0/rsls/loader_animation.swf\n"
- + ((flaVersion.ordinal()>=FLAVersion.CC.ordinal())?(
- " \n"
+ + ((flaVersion.ordinal() >= FLAVersion.CC.ordinal()) ? (" \n"
+ " \n"
+ " $(AppConfig)/ActionScript 3.0/libs\n"
+ " merge\n"
@@ -2721,9 +2737,8 @@ public class XFLConverter {
+ " \n"
+ " \n"
+ " \n"
- + " "):
-
- " \n"
+ + " ")
+ : " \n"
+ " \n"
+ " $(AppConfig)/ActionScript 3.0/libs\n"
+ " merge\n"
@@ -2745,8 +2760,6 @@ public class XFLConverter {
+ " textLayout_2.0.0.232.swz\n"
+ " \n"
+ " \n")
-
-
+ " \n"
+ " \n"
+ " " + width + "\n"
@@ -2810,9 +2823,8 @@ public class XFLConverter {
+ " 255\n"
+ " \n"
+ " \n"
-
- + ((flaVersion.ordinal()>=FLAVersion.CC.ordinal())?"":
- (" \n"
+ + ((flaVersion.ordinal() >= FLAVersion.CC.ordinal()) ? ""
+ : (" \n"
+ " " + width + "\n"
+ " " + height + "\n"
+ " 1\n"