From 7839a9cc08bec52fe024d43eace5c90c6d159c1f Mon Sep 17 00:00:00 2001 From: George FunBook Date: Wed, 16 Feb 2022 15:21:37 -0600 Subject: [PATCH 1/9] add setChildField to prevent errors on static targets --- src/swf/runtime/MovieClip.hx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/swf/runtime/MovieClip.hx b/src/swf/runtime/MovieClip.hx index e8932fb..02505a3 100644 --- a/src/swf/runtime/MovieClip.hx +++ b/src/swf/runtime/MovieClip.hx @@ -218,7 +218,20 @@ class MovieClipTimeline extends Timeline } #if !flash + setChildField(displayObject); + #end + } + + @:noCompletion private inline function setChildField(displayObject:DisplayObject) + { + #if (openfl_dynamic && haxe_ver < "4.0.0") Reflect.setField(movieClip, displayObject.name, displayObject); + #else + // Check that the type allows this field + if (Type.getInstanceFields(Type.getClass(movieClip)).indexOf(displayObject.name) != -1) + { + Reflect.setField(movieClip, displayObject.name, displayObject); + } #end } From 16c9bd3daa54df5ed3beeeb35e1f07c6c7d49d5b Mon Sep 17 00:00:00 2001 From: George FunBook Date: Wed, 16 Feb 2022 15:24:53 -0600 Subject: [PATCH 2/9] render first frame on instatiate --- src/swf/runtime/MovieClip.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/swf/runtime/MovieClip.hx b/src/swf/runtime/MovieClip.hx index 02505a3..7511fea 100644 --- a/src/swf/runtime/MovieClip.hx +++ b/src/swf/runtime/MovieClip.hx @@ -22,6 +22,10 @@ class MovieClip extends #if flash openfl.display.MovieClip.MovieClip2 #else open { super(); attachTimeline(new MovieClipTimeline(data)); + + #if !flash + __enterFrame(0); + #end } } From 24960f599df18d5995d7bdc742dbe0cfe8899fcf Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 17 Feb 2022 17:13:45 -0600 Subject: [PATCH 3/9] isOfType helper --- src/swf/exporters/swflite/SpriteSymbol.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/swf/exporters/swflite/SpriteSymbol.hx b/src/swf/exporters/swflite/SpriteSymbol.hx index 587850b..3125c4f 100644 --- a/src/swf/exporters/swflite/SpriteSymbol.hx +++ b/src/swf/exporters/swflite/SpriteSymbol.hx @@ -7,6 +7,8 @@ import openfl.display.DisplayObject; import openfl.display.MovieClip; import openfl.geom.Rectangle; +import #if (haxe_ver >= 4.2) Std.isOfType #else Std.is as isOfType #end; + #if !openfl_debug @:fileXml('tags="haxe,release"') @:noDebug @@ -97,7 +99,7 @@ class SpriteSymbol extends SWFSymbol } #if flash - if (!#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (movieClip, flash.display.MovieClip.MovieClip2)) + if (!isOfType(movieClip, flash.display.MovieClip.MovieClip2)) { movieClip.scale9Grid = scale9Grid; } From a95d64b5007e9d294ab807bd2a3aef5aad3526da Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 17 Feb 2022 17:21:07 -0600 Subject: [PATCH 4/9] update deprecated MovieClip.__constructor --- src/swf/exporters/swflite/SpriteSymbol.hx | 32 +++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/swf/exporters/swflite/SpriteSymbol.hx b/src/swf/exporters/swflite/SpriteSymbol.hx index 3125c4f..b16cd0b 100644 --- a/src/swf/exporters/swflite/SpriteSymbol.hx +++ b/src/swf/exporters/swflite/SpriteSymbol.hx @@ -5,6 +5,7 @@ import swf.exporters.swflite.timeline.Frame; import swf.exporters.swflite.timeline.SymbolTimeline; import openfl.display.DisplayObject; import openfl.display.MovieClip; +import openfl.display.Sprite; import openfl.geom.Rectangle; import #if (haxe_ver >= 4.2) Std.isOfType #else Std.is as isOfType #end; @@ -13,7 +14,6 @@ import #if (haxe_ver >= 4.2) Std.isOfType #else Std.is as isOfType #end; @:fileXml('tags="haxe,release"') @:noDebug #end -@:access(openfl.display.MovieClip) class SpriteSymbol extends SWFSymbol { public var baseClassName:String; @@ -29,7 +29,15 @@ class SpriteSymbol extends SWFSymbol frames = new Array(); } - private function __constructor(movieClip:MovieClip):Void + private function __spriteConstructor(sprite:Sprite):Void + { + if (!isOfType(sprite, MovieClip)) + throw "expected movieclip"; + + __movieClipConstructor(cast sprite); + } + + private function __movieClipConstructor(movieClip:MovieClip):Void { var timeline = new SymbolTimeline(swf, this); #if flash @@ -40,11 +48,21 @@ class SpriteSymbol extends SWFSymbol movieClip.scale9Grid = scale9Grid; } - private override function __createObject(swf:SWFLite):MovieClip + private inline function __setConstructor() { #if (!macro && !flash) - MovieClip.__constructor = __constructor; + @:privateAccess + #if (openfl <= "9.1.0") + MovieClip.__constructor = __movieClipConstructor; + #else + Sprite.__constructor = __spriteConstructor; + #end #end + } + + private override function __createObject(swf:SWFLite):MovieClip + { + __setConstructor(); this.swf = swf; #if flash @@ -110,15 +128,13 @@ class SpriteSymbol extends SWFSymbol private override function __init(swf:SWFLite):Void { - #if (!macro && !flash) - MovieClip.__constructor = __constructor; - #end + __setConstructor(); this.swf = swf; } private override function __initObject(swf:SWFLite, instance:DisplayObject):Void { this.swf = swf; - __constructor(cast instance); + __movieClipConstructor(cast instance); } } From c5c4eac9443bcd532bf09e7cf673a38638f1f076 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 22 Feb 2022 13:34:15 -0600 Subject: [PATCH 5/9] fix `createMovieClip` and `createButton` --- src/swf/SWF.hx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/swf/SWF.hx b/src/swf/SWF.hx index 5053fbb..a3018f6 100644 --- a/src/swf/SWF.hx +++ b/src/swf/SWF.hx @@ -109,11 +109,10 @@ class SWF extends EventDispatcher symbol = data.getCharacter(charId); } - // if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (symbol, TagDefineButton2)) { - - // return new SimpleButton (data, cast symbol); - - // } + if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (symbol, TagDefineButton2)) + { + return new swf.runtime.SimpleButton(data, cast symbol); + } return null; } @@ -143,11 +142,10 @@ class SWF extends EventDispatcher } } - // if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (symbol, SWFTimelineContainer)) { - - // return new MovieClip (cast symbol); - - // } + if (#if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (symbol, SWFTimelineContainer)) + { + return new swf.runtime.MovieClip(cast symbol); + } return null; } From 093e2414ad95664bccae14c79b74b3fa438e6573 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 3 Mar 2022 10:40:54 -0600 Subject: [PATCH 6/9] prevent duplicate matrix multiplication --- src/swf/exporters/SWFLiteExporter.hx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/swf/exporters/SWFLiteExporter.hx b/src/swf/exporters/SWFLiteExporter.hx index 5a741b4..718ab9c 100644 --- a/src/swf/exporters/SWFLiteExporter.hx +++ b/src/swf/exporters/SWFLiteExporter.hx @@ -1,6 +1,7 @@ package swf.exporters; import openfl.display.BitmapData; +import openfl.geom.Matrix; import openfl.text.TextFormatAlign; import openfl.utils.ByteArray; import format.png.Data; @@ -555,7 +556,9 @@ class SWFLiteExporter if (placeTag.matrix != null) { - var matrix = placeTag.matrix.matrix; + var matrix = new Matrix(); + matrix.copyFrom(placeTag.matrix.matrix); + matrix.tx *= (1 / 20); matrix.ty *= (1 / 20); @@ -807,7 +810,8 @@ class SWFLiteExporter symbol.records = records; - var matrix = tag.textMatrix.matrix; + var matrix = new Matrix(); + matrix.copyFrom(tag.textMatrix.matrix); matrix.tx *= (1 / 20); matrix.ty *= (1 / 20); From 7278852c8f79f1669e3d12c41a766dfb9ff3f6d6 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 3 Mar 2022 11:10:42 -0600 Subject: [PATCH 7/9] fix multiple matrix scales again, but with less instances --- src/swf/exporters/SWFLiteExporter.hx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/swf/exporters/SWFLiteExporter.hx b/src/swf/exporters/SWFLiteExporter.hx index 718ab9c..9be952a 100644 --- a/src/swf/exporters/SWFLiteExporter.hx +++ b/src/swf/exporters/SWFLiteExporter.hx @@ -556,11 +556,9 @@ class SWFLiteExporter if (placeTag.matrix != null) { - var matrix = new Matrix(); - matrix.copyFrom(placeTag.matrix.matrix); - - matrix.tx *= (1 / 20); - matrix.ty *= (1 / 20); + var matrix = placeTag.matrix.matrix; + matrix.tx = placeTag.matrix.translateX / 20; + matrix.ty = placeTag.matrix.translateY / 20; frameObject.matrix = matrix; } @@ -809,11 +807,10 @@ class SWFLiteExporter } symbol.records = records; - - var matrix = new Matrix(); - matrix.copyFrom(tag.textMatrix.matrix); - matrix.tx *= (1 / 20); - matrix.ty *= (1 / 20); + + var matrix = tag.textMatrix.matrix; + matrix.tx = tag.textMatrix.translateX / 20; + matrix.ty = tag.textMatrix.translateY / 20; symbol.matrix = matrix; From 6022a9cde100f9d03c3f2c0928e2ea1b8e9ef44b Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 3 Mar 2022 11:21:27 -0600 Subject: [PATCH 8/9] fix buttons too --- src/swf/exporters/SWFLiteExporter.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/swf/exporters/SWFLiteExporter.hx b/src/swf/exporters/SWFLiteExporter.hx index 9be952a..b60130e 100644 --- a/src/swf/exporters/SWFLiteExporter.hx +++ b/src/swf/exporters/SWFLiteExporter.hx @@ -136,8 +136,8 @@ class SWFLiteExporter if (object.placeMatrix != null) { var matrix = object.placeMatrix.matrix; - matrix.tx *= (1 / 20); - matrix.ty *= (1 / 20); + matrix.tx = object.placeMatrix.translateX / 20; + matrix.ty = object.placeMatrix.translateY / 20; frameObject.matrix = matrix; } From ed15b9a4aada254e079cf0fa17406762b672e2ab Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 3 Mar 2022 11:22:58 -0600 Subject: [PATCH 9/9] import --- src/swf/exporters/SWFLiteExporter.hx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/swf/exporters/SWFLiteExporter.hx b/src/swf/exporters/SWFLiteExporter.hx index b60130e..e1dbaad 100644 --- a/src/swf/exporters/SWFLiteExporter.hx +++ b/src/swf/exporters/SWFLiteExporter.hx @@ -1,7 +1,6 @@ package swf.exporters; import openfl.display.BitmapData; -import openfl.geom.Matrix; import openfl.text.TextFormatAlign; import openfl.utils.ByteArray; import format.png.Data;