Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/swf/exporters/animate/AnimateTimeline.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import hscript.Parser;
@:access(openfl.geom.ColorTransform)
class AnimateTimeline extends Timeline
{
@:noCompletion private static var __instanceFieldsCacheByClassName:Map<String, Array<String>> = new Map();

#if 0
// Suppress checkstyle warning
private static var __unusedImport:Array<Class<Dynamic>> = [
Expand Down Expand Up @@ -420,7 +422,7 @@ class AnimateTimeline extends Timeline
}

#if !openfljs
__instanceFields = Type.getInstanceFields(Type.getClass(__sprite));
__instanceFields = __getCachedInstanceFields(__sprite);
#end

enterFrame(1);
Expand Down Expand Up @@ -496,7 +498,7 @@ class AnimateTimeline extends Timeline

displayObject.filters = filters;
}
else
else if (reset && displayObject.filters != null)
{
displayObject.filters = null;
}
Expand Down Expand Up @@ -547,6 +549,30 @@ class AnimateTimeline extends Timeline
}
}

@:noCompletion private static function __getCachedInstanceFields(displayObject:DisplayObject):Array<String>
{
var clazz = Type.getClass(displayObject);
if (clazz == null)
{
return [];
}

var className = Type.getClassName(clazz);
if (className == null)
{
return Type.getInstanceFields(clazz);
}

var cached = __instanceFieldsCacheByClassName.get(className);
if (cached == null)
{
cached = Type.getInstanceFields(clazz);
__instanceFieldsCacheByClassName.set(className, cached);
}

return cached;
}

#if hscript
@:noCompletion private function __createScriptCallback(parser:Parser, scriptSource:String):MovieClip->Void
{
Expand Down
30 changes: 28 additions & 2 deletions src/swf/exporters/swflite/timeline/SymbolTimeline.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import hscript.Parser;
@:access(openfl.geom.ColorTransform)
class SymbolTimeline extends Timeline
{
@:noCompletion private static var __instanceFieldsCacheByClassName:Map<String, Array<String>> = new Map();

#if openfljs
@:noCompletion private static var __useParentFPS:Bool;
#else
Expand Down Expand Up @@ -256,7 +258,7 @@ class SymbolTimeline extends Timeline
}

#if !openfljs
__instanceFields = Type.getInstanceFields(Type.getClass(movieClip));
__instanceFields = __getCachedInstanceFields(movieClip);
#end

enterFrame(1);
Expand Down Expand Up @@ -468,7 +470,7 @@ class SymbolTimeline extends Timeline

displayObject.filters = filters;
}
else
else if (reset && displayObject.filters != null)
{
displayObject.filters = null;
}
Expand Down Expand Up @@ -511,6 +513,30 @@ class SymbolTimeline extends Timeline
}
}
}

@:noCompletion private static function __getCachedInstanceFields(displayObject:DisplayObject):Array<String>
{
var clazz = Type.getClass(displayObject);
if (clazz == null)
{
return [];
}

var className = Type.getClassName(clazz);
if (className == null)
{
return Type.getInstanceFields(clazz);
}

var cached = __instanceFieldsCacheByClassName.get(className);
if (cached == null)
{
cached = Type.getInstanceFields(clazz);
__instanceFieldsCacheByClassName.set(className, cached);
}

return cached;
}
}

#if !openfl_debug
Expand Down