Html5 can not load the txt file

Hello,everyone.
I add a txt to the assets,but it did not work.

I got an error:Preloader.hx:185: Error loading asset “assets/o.txt”


when I add a png,it was work.

Why can’t I add a txt file?

HELP ME

THANKS!

HELP ME!
I don’t know how should i do.

Are you trying to load this during the preloader?

I just added it to the assets.Then I can not load the web page.

What version of OpenFL are you using? Also, are you using a custom preloader?

4.7.3,I am not using a custom preloader.I just getText(“assets/o.txt”);
But when I deleted this line of code,I still can’t see the web page.

Does o.txt have any text in it?

That makes sense. The problem happens during the preloader, which runs whether or not you call getText().

The error message comes from this line, which really doesn’t tell us much. That function is added as a listener here, the listener is triggered because loadText() encountered an error, and loadText() calls loadBytes(). This brings us to Bytes.loadFromFile(), which calls _HTTPRequest_Bytes.load(), which calls HTML5HTTPRequest.loadData(), which seems to be what creates the error.

It throws the error based on an HTTP response code, but sadly, that code isn’t included in the error message. Try adding a trace() statement here. For instance:

} else {
	
	processResponse ();
	trace ("HTTP error " + request.status);
	promise.error (request.status);
	
}

I got "HTML5HTTPRequest.hx:155: HTTP error 0
"
Then how should I do?

Well that isn’t a valid HTTP status code, but apparently it has some other meanings.

Let’s print some more data:

} else {
	
	processResponse ();
	
	trace ("status: " + request.status);
	trace ("statusText: " + request.statusText);
	trace ("readyState: " + request.readyState);
	trace ("responseText: " + request.responseText);
	
	promise.error (request.status);
	
}

Actually, maybe it would work better to approach this from another angle.

Does o.txt have any text? If so, what happens if you remove the text?

Does Export/html5/release/bin/assets/o.txt exist? (Or look in Export/html5/debug if you’re building in debug mode.)

I added something to the project.xml.Then it worked.
<?xml version="1.0" encoding="utf-8"?>

<meta title="Cloudide" package="com.sample.cloudide" version="1.0.0" company="Company Name" />
<app main="Main" path="Export" file="Cloudide" />

<source path="Source" />
<haxelib name="openfl" />

<assets path="Assets" rename="assets" embed="false"/>

I added "embed=“false”.

Thanks.

I wonder if it’s related to this fix:

I just ran some tests, the above example is working with embed="true" and embed="false", so if there’s a regression in the current release, it should be fixed when we push the next update :slight_smile: