You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
Map is loaded from the SharedObject
Screenshots
TypeError: Error #1034: Type Coercion failed: cannot convert Object@2800c5302e51 to haxe.IMap.
at Main/load()[/Projects/Haxe/issues/SharedObjectMaps/Source/Main.hx:28]
OpenFL Targets
Flash
Additional context
Does not occur on other targets.
The text was updated successfully, but these errors were encountered:
With SharedObject and ByteArray, only the core AS3 language types can be serialized automatically. As I understand it, custom types need to implement flash.utils.IExternalizable to be restored when read from a SharedObject or a ByteArray (and i think maybe flash.net.registerClassAlias needs to be involved too).
Since haxe.IMap does not implement the IExternalizable interface, and we can't force it to implement that interface because it's a Haxe core language type that isn't under OpenFL's control, there probably isn't much that can be done to improve this situation. You may want to consider using a different type that can be serialized. For instance, Flash's Dictionary type is relatively similar to Map (though it isn't strictly typed like Map, so it's not a perfect replacement).
It may also be possible to create a custom IMap implementation that also implements IExternalizable. It could use a regular Map internally to store the data, and act as kind of a wrapper. I've never tried this myself, but it might be something to look into, if you really want to use a map, and would prefer to avoid another type.
Describe the bug
Type coercion fails when attempting to use a map loaded from a SharedObject in the Flash target.
Steps to Reproduce
Minimal Example
Expected behavior
Map is loaded from the SharedObject
Screenshots
OpenFL Targets
Flash
Additional context
Does not occur on other targets.
The text was updated successfully, but these errors were encountered: