Getting a class from a loaded SWF?

Hi, I’m trying to convert an old flash project to OpenFl. So far I managed to overcome a lot of problems and it’s fine.

Part of the initialization of the game was to load a swf and create instances that was exported from the library.

The “Flash” way of doing it failed:

content.loaderInfo.applicationDomain.getDefinition(name);

With or without casting, throws an exception that the definition in name does not exist. However, the correct file was loaded and added to stage, I can see it’s graphics, and the definition does exist in the file.

Trying to use SWF library, just shouts a lot of compilation errors (of course, I’ve upgraded all the libraries in advance):

C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:15: characters 18-26 : format.swf.utils.BitArray has no field get
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:62: characters 4-12 : format.swf.utils.BitArray has no field set
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:62: characters 28-36 : format.swf.utils.BitArray has no field get
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:66: characters 4-12 : format.swf.utils.BitArray has no field set
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:66: characters 28-36 : format.swf.utils.BitArray has no field get
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:70: characters 4-12 : format.swf.utils.BitArray has no field set
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/utils/BitArray.hx:70: characters 28-36 : format.swf.utils.BitArray has no field get
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/SWFData.hx:310: characters 9-17 : format.swf.utils.BitArray has no field get
C:/HaxeToolkit/haxe/lib/swf/2,1,6/format/swf/SWFData.hx:872: characters 17-25 : format.swf.utils.BitArray has no field get

Any advice, please?

Ok, scratch the first question. I wasn’t paying attention in the translation of this particular function.
However, What I’ve read is that this method only works on flash target. My goal is eventually HTML5, so will I need to use SWF?

In HTML5, you need to compile all of it together right now. However, we’re working on a method of splitting up code, we’re interested in looking at “openfl.js” as a separate file, and have made good progress towards this goal.

Perhaps you can use untyped or extern to try and load code compiled separately? There’s an @:expose tag that helps make objects visible to other JS files