diff --git a/CHANGELOG.md b/CHANGELOG.md index a46d29f6d..d258bf6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - Folder preview - GFX image identifiers not shown - Hide zooming buttons in fonts display - [#2174] Ignoring PlaceObjects with flagMove on empty depth +- [#2175] Removing DefineButtonSound, warning about incorrect sound character type in FLA export ## [20.1.0] - 2023-12-30 ### Added @@ -3363,6 +3364,7 @@ Major version of SWF to XML export changed to 2. [#2149]: https://www.free-decompiler.com/flash/issues/2149 [#2172]: https://www.free-decompiler.com/flash/issues/2172 [#2174]: https://www.free-decompiler.com/flash/issues/2174 +[#2175]: https://www.free-decompiler.com/flash/issues/2175 [#2100]: https://www.free-decompiler.com/flash/issues/2100 [#2123]: https://www.free-decompiler.com/flash/issues/2123 [#2119]: https://www.free-decompiler.com/flash/issues/2119 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java index 130abe3dc..a7db2951c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java @@ -162,4 +162,66 @@ public class DefineButtonSoundTag extends Tag implements CharacterIdTag { public String toString() { return super.toString() + " (" + buttonId + ")"; } + + @Override + public boolean removeCharacter(int characterId) { + boolean modified = false; + + if (buttonSoundChar0 == characterId) { + buttonSoundChar0 = 0; + buttonSoundInfo0 = null; + modified = true; + } + if (buttonSoundChar1 == characterId) { + buttonSoundChar1 = 0; + buttonSoundInfo1 = null; + modified = true; + } + if (buttonSoundChar2 == characterId) { + buttonSoundChar2 = 0; + buttonSoundInfo2 = null; + modified = true; + } + if (buttonSoundChar3 == characterId) { + buttonSoundChar3 = 0; + buttonSoundInfo3 = null; + modified = true; + } + + if (modified) { + setModified(true); + } + return modified; + } + + @Override + public boolean replaceCharacter(int oldCharacterId, int newCharacterId) { + boolean modified = false; + + if (buttonId == oldCharacterId) { + buttonId = newCharacterId; + modified = true; + } + if (buttonSoundChar0 == oldCharacterId) { + buttonSoundChar0 = newCharacterId; + modified = true; + } + if (buttonSoundChar1 == oldCharacterId) { + buttonSoundChar1 = newCharacterId; + modified = true; + } + if (buttonSoundChar2 == oldCharacterId) { + buttonSoundChar2 = newCharacterId; + modified = true; + } + if (buttonSoundChar3 == oldCharacterId) { + buttonSoundChar3 = newCharacterId; + modified = true; + } + + if (modified) { + setModified(true); + } + return modified; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index fd05c218d..b800884a6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -1811,8 +1811,15 @@ public class XFLConverter { "index", Integer.toString(frame - 1), "keyMode", Integer.toString(KEY_MODE_NORMAL)}); if (soundChar > 0) { - DefineSoundTag sound = (DefineSoundTag) swf.getCharacter(soundChar); - convertSoundUsage(symbolStr, sound, soundInfo); + CharacterTag soundCharTag = swf.getCharacter(soundChar); + if (soundCharTag == null) { + logger.log(Level.WARNING, "Sound tag (ID={0}) was not found", soundChar); + } else if (soundCharTag instanceof DefineSoundTag) { + DefineSoundTag sound = (DefineSoundTag) soundCharTag; + convertSoundUsage(symbolStr, sound, soundInfo); + } else { + logger.log(Level.WARNING, "Tag (ID={0}) expected to be DefineSound, {1} found. It is referenced from DefineButtonSound({2}).", new Object[] {soundChar, soundCharTag.getClass().getSimpleName(), defineButtonSound.buttonId}); + } } symbolStr.writeStartElement("elements"); symbolStr.writeEndElement(); //elements diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index a54437ce8..1793c85cb 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -2308,7 +2308,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (button != null && freeTransformDepth == -1) { DefineButtonSoundTag sounds = button.getSounds(); if (!muted && sounds != null && sounds.buttonSoundChar2 != 0) { // OverUpToOverDown - playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar2), sounds.buttonSoundInfo2, timer); + CharacterTag soundCharTag = swf.getCharacter(sounds.buttonSoundChar2); + if (soundCharTag instanceof SoundTag) { + playSound((SoundTag) soundCharTag, sounds.buttonSoundInfo2, timer); + } } List actions = new ArrayList<>(); if (button instanceof DefineButton2Tag) { @@ -2350,7 +2353,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (!muted && button != null && freeTransformDepth == -1) { DefineButtonSoundTag sounds = button.getSounds(); if (sounds != null && sounds.buttonSoundChar3 != 0) { // OverDownToOverUp - playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar3), sounds.buttonSoundInfo3, timer); + CharacterTag soundCharTag = swf.getCharacter(sounds.buttonSoundChar3); + if (soundCharTag instanceof SoundTag) { + playSound((SoundTag) soundCharTag, sounds.buttonSoundInfo3, timer); + } } } } @@ -3484,7 +3490,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { // New mouse entered DefineButtonSoundTag sounds = b.getSounds(); if (sounds != null && sounds.buttonSoundChar1 != 0) { // IdleToOverUp - playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar1), sounds.buttonSoundInfo1, timer); + CharacterTag soundCharTag = swf.getCharacter(sounds.buttonSoundChar1); + if (soundCharTag instanceof SoundTag) { + playSound((SoundTag) soundCharTag, sounds.buttonSoundInfo1, timer); + } } } @@ -3493,7 +3502,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { // Old mouse leave DefineButtonSoundTag sounds = b.getSounds(); if (sounds != null && sounds.buttonSoundChar0 != 0) { // OverUpToIdle - playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar0), sounds.buttonSoundInfo0, timer); + CharacterTag soundCharTag = swf.getCharacter(sounds.buttonSoundChar0); + if (soundCharTag instanceof SoundTag) { + playSound((SoundTag) soundCharTag, sounds.buttonSoundInfo0, timer); + } } } }