Last active
January 14, 2019 21:22
-
-
Save mrchnk/ef7d5525ee326c96cceddf758aad0eef to your computer and use it in GitHub Desktop.
Workaround for RSL-linked items in swf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/scripts/format/swf/SWFRoot.hx b/scripts/format/swf/SWFRoot.hx | |
| index 626f59d..33ecf86 100644 | |
| --- a/scripts/format/swf/SWFRoot.hx | |
| +++ b/scripts/format/swf/SWFRoot.hx | |
| @@ -13,6 +13,8 @@ import flash.utils.ByteArray; | |
| import flash.utils.CompressionAlgorithm; | |
| import flash.errors.Error; | |
| import format.swf.tags.TagSymbolClass; | |
| +import format.swf.tags.TagPlaceObject; | |
| +import format.swf.tags.TagDefineSprite; | |
| class SWFRoot extends SWFTimelineContainer | |
| @@ -65,6 +67,7 @@ class SWFRoot extends SWFTimelineContainer | |
| } | |
| + linkSymbols (this); | |
| #if test_abc | |
| if (abcData != null) bindABCWithSymbols(); | |
| @@ -73,6 +76,39 @@ class SWFRoot extends SWFTimelineContainer | |
| } | |
| + private function linkSymbols(timeline:SWFTimelineContainer):Void { | |
| + for (tag in timeline.tags) { | |
| + if (Std.is (tag, TagDefineSprite)) { | |
| + linkSymbols (cast (tag, TagDefineSprite)); | |
| + } else if (Std.is (tag, TagPlaceObject)) { | |
| + var placeObject = cast (tag, TagPlaceObject); | |
| + if (placeObject.hasClassName && !placeObject.hasCharacter) { | |
| + var className = placeObject.className; | |
| + if (symbols.exists (className)) { | |
| + placeObject.hasCharacter = true; | |
| + placeObject.hasClassName = false; | |
| + placeObject.characterId = symbols.get (className); | |
| + } else { | |
| + throw new Error("Undefined symbol " + className); | |
| + } | |
| + } | |
| + } | |
| + } | |
| + for (frame in timeline.frames) { | |
| + for (object in frame.objects) { | |
| + var className = object.className; | |
| + if (className != null) { | |
| + if (symbols.exists (className)) { | |
| + object.className = null; | |
| + object.characterId = symbols.get (className); | |
| + } else { | |
| + throw new Error("Undefined symbol " + className); | |
| + } | |
| + } | |
| + } | |
| + } | |
| + } | |
| + | |
| #if test_abc | |
| function bindABCWithSymbols() | |
| { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment