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; } diff --git a/src/swf/exporters/SWFLiteExporter.hx b/src/swf/exporters/SWFLiteExporter.hx index 5a741b4..e1dbaad 100644 --- a/src/swf/exporters/SWFLiteExporter.hx +++ b/src/swf/exporters/SWFLiteExporter.hx @@ -135,8 +135,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; } @@ -556,8 +556,8 @@ class SWFLiteExporter if (placeTag.matrix != null) { var matrix = placeTag.matrix.matrix; - matrix.tx *= (1 / 20); - matrix.ty *= (1 / 20); + matrix.tx = placeTag.matrix.translateX / 20; + matrix.ty = placeTag.matrix.translateY / 20; frameObject.matrix = matrix; } @@ -806,10 +806,10 @@ class SWFLiteExporter } symbol.records = records; - + var matrix = tag.textMatrix.matrix; - matrix.tx *= (1 / 20); - matrix.ty *= (1 / 20); + matrix.tx = tag.textMatrix.translateX / 20; + matrix.ty = tag.textMatrix.translateY / 20; symbol.matrix = matrix; diff --git a/src/swf/exporters/swflite/SpriteSymbol.hx b/src/swf/exporters/swflite/SpriteSymbol.hx index 587850b..b16cd0b 100644 --- a/src/swf/exporters/swflite/SpriteSymbol.hx +++ b/src/swf/exporters/swflite/SpriteSymbol.hx @@ -5,13 +5,15 @@ 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; + #if !openfl_debug @:fileXml('tags="haxe,release"') @:noDebug #end -@:access(openfl.display.MovieClip) class SpriteSymbol extends SWFSymbol { public var baseClassName:String; @@ -27,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 @@ -38,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 @@ -97,7 +117,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; } @@ -108,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); } } diff --git a/src/swf/runtime/MovieClip.hx b/src/swf/runtime/MovieClip.hx index e8932fb..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 } } @@ -218,7 +222,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 }