Loading external assets on Windows target ( URLLoader problem )

Hey !

I am having problem with URLLoader, on Flash it works fine, but on Windows target loading never ends
I put the files in the bin folder in both flash and windows/cpp folders

In documentation it says that URLLoader works only for Flash http://api.haxe.org/flash/net/URLLoader.html#
But why the compiling works and I don’t get any errors after ?

I need to load assets after the game is compiled so that writer can change scripts in this text files.
How can I do this on Windows ? Thanks ! :smile:

URLLoader should work on Windows. That documentation is for plain Haxe while OpenFL is a framework that recreates most of the Flash API for use on Windows and other platforms. See here:


Not sure why it would never end though… Maybe try adding the complete event listener before you call load.

Okay I tried calling addEventListener before load, but it didn’t change anything, it still never completes.

Like I said, on Flash it all works fine with the same code.

Maybe the files I am trying to load are at wrong place ?
For Windows they are in bin/windows/cpp/bin/data/scripts ( the .exe file is in bin/windows/cpp/bin )
And this is the path I am trying to load :
public static var TextChaptersDefinitions:String = “data/scripts/_chapters.txt”;

If you want the text file to live with the exe rather than being in a separate place (e.g. from a web server) then why not just use OpenFL’s assets system?


You can use Assets.getText() to read a text file.

I need the text to be outside of the .exe so that writer can edit them and test the game without compiling it.

If you are only reading on desktop you could simply access the text file directly.

TextChaptersDefinitions = sys.io.File.getContent("data/scripts/_chapters.txt");

The project building only list assets, so if the files themselves (not their content) don’t change you can use the Asset system.

I tried changing the art without compiling after, but the art in SWF file didn’t change.
This means I cannot use Assets system for this since writer needs to be able to change the stuff without compiling it. I cannot send him the source code.

It would be great if same system would be used both for Flash and Windows, so if I don’t find solution that works for above problem, I will try File.getContent. The whole code is already built around working with URLLoaders.

Usually for testing I compile to SWF because testing for Windows takes a lot of time and testing in Neko is not possible because there is lot of stuff going on the screen.

Oh I see, well that’s because the swf file include the text files, so you don’t actually edit them, therefor nothing changed.

But on the html5, neko and desktop targets the files are next to the executable (or js file for html5), so if you edit them it’ll work without having to recompile.
I’m talking about files in bin/windows/bin/data/ not data/ (or assets/data, don’t know how you called it).

If you want you can do openfl update windows which will update the assets next to the executable from your project assets.

Yeah I have the files already there, but I am using URLLoader.

So you are suggesting that I use sys.io.File.getContent, I was confused since you also mentioned Asset system so I was thinking you are saying that I also try Assets.getText.

Like I said, I still would prefer if I could make URLLoaders work since the code is already using it and the game is multiplatform.

It seems this could be related :