Openfl.display.Loader loadBytes compile error

I’m getting the following compile errors on targets other than flash for the “loader.loadBytes(bytes, loaderContext);” line in the following code:

    var loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    loaderContext.allowCodeImport = true;
    var loader: Loader = new Loader();
    var req = new URLRequest(url);
    var urlLoader = new URLLoader(req);
    urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
    urlLoader.addEventListener(Event.COMPLETE, function(event: Event) {
        var bytes: ByteArray = getEventData(event);
        loader.loadBytes(bytes, loaderContext);
    });

Too many arguments
Function ‘loadBytes’ requires arguments : buffer

This compiles and runs for the flash target. E.g. this gets the error:

openfl test neko

This does not:

openfl test flash

This should be resolved in current releases :slight_smile:

1 Like

Thanks for the quick response!
I updated openfl and lime

haxelib update openfl
haxelib update lime

and now I get this compile error:

$ openfl test flash
/usr/lib/haxe/lib/openfl/3,5,3/extern/flash/display3D/Context3D.hx:62: characters 54-123 : Class not found : flash.display3D.textures.VideoTexture

and this for neko:

$ openfl test neko
/usr/lib/haxe/lib/openfl/3,5,3/openfl/utils/ByteArray.hx:118: characters 9-59 : openfl.utils.ByteArrayData should be openfl.utils.ByteArray

I’m guessing I did not do the update properly or completely, any help appreciated!

Could you make sure you have Haxe 3.2 or 3.2.1 installed? Thanks!

1 Like

Thanks, that was the problem!

1 Like

I have some more issues that I’m guessing are a problem with updating libraries, but I did

$ openfl upgrade
openfl is up to date
lime is up to date
hxcpp is up to date
lime-samples is up to date
openfl-samples is up to date
actuate is up to date
box2d is up to date
layout is up to date
swf is up to date

and

$ haxe -version
3.2.1

I’m working on loading a swf asset at runtime and getting these compile errors:

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

Any help on what I might be doing wrong appreciated!

fwiw, I tried cloning the swf repo and using that - get the same errors

Also, my ultimate goal is to see if I can load an asset swf in HTML5 (for desktop browser). I’m trying to compile for flash here because I’m assuming that will be the most likely to work.

Could you try one of the OpenFL SWF-based samples, such as “NyanCat” or “SimpleSWFLayout” and see if those work?

NyanCat compiles and runs fine, tried Flash and HTML5

Okay, well that means the SWF library should be working for both Flash and HTML5. Not sure what went wrong in the other project?

Right, I’ll try to narrow it down. Thanks for your help

I got the line generating the compile errors from this post:

this line:

var swf = new format.SWF (bytes);

If I comment it out, I don’t get the compile errors I listed earlier in this thread.
I’ve been looking for a way to load a swf at runtime outside the flash target, and I thought this was supposed to create a swf object from a loaded byteArray… We don’t have any bytecode in the swfs to be loaded

Oh, gotcha :slightly_smiling:

That’s “swf”, “swflite” works at compile-time only right now, but that’s what HTML5 relies upon. I think we could do more to allow for “swflite” loading at runtime, but that’s the key you need for all targets outside Flash

Thanks for the reply!

So by loading at runtime, this means loading swf data that was incorporated at compile time?
This area is very confusing, and in researching it, I’ve found a lot of other people who are similarly confused.
Would you say it is worth pursuing to attempt to load a swf at runtime that only has graphic assets (no bytecode or even sound) for an HTML5 target? Or is there an OpenFl way to convert a swf to assets that are more amenable to loading in an HTML5 target?

Compiling with “swflite” pre-digests the SWF into a new format that’s more suitable for HTML5. In practice, this is now something we could load at runtime – and we do. The trick is just working out the tooling for pre-generating the SWFLite output, then fetching it at runtime on a server

1 Like

I am having the same problem:

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

Although I am using haxe 3.2.1, here is my stack:

actuate: [1.8.6]
assetsmanager: [1.2.0]
box2d: [1.2.3]
cereal: [0.0.4]
crashdumper: git [dev:H:\haxelibs\lib\crashdumper\git]
extension-nativedialog: 1.2.1 [1.2.2]
files-viewer: [dev:H:\repositories\dcaclab-app\files-viewer\src]
format: [3.2.1]
haxeui-file-dialogs: [0.1.1]
haxeui: 1.7.18 [1.8.17]
hscript: 2.0.4 [2.0.5]
hxcpp: 3.2.180 [3.2.205]
layout: [1.2.1]
lime-samples: [2.6.0]
lime: [2.9.0]
mlib: [2.0.2]
msignal: 1.2.2 [1.2.4]
openfl-samples: [3.3.1]
openfl: [3.6.0]
rox-i18n: [1.0.0]
stablexui: [1.1.5]
svg: 1.0.8 [1.0.9]
swf: 2.1.0 [2.2.0]
systools: [1.1.0]
tjson: [1.4.0]

Please help!