openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
754 stars 370 forks source link

HTML5 Builds failing to preload #1632

Open SlickFromMars opened 1 year ago

SlickFromMars commented 1 year ago
image

When compiling my HaxeFlixel project to html5 using lime, the preloader gets stuck here when I click on the html5 file. I am aware that it will work when I use the lime run html5 command in the root, but I want to deploy the app to a website and I don't want users to run into this issue.

Does anyone have a solution?

Source code is here if you need it.

player-03 commented 1 year ago

Try pressing ctrl+shift+I (or right-click → inspect) to open the developer tools. The console tab will probably have an error message with more details.

Odds are, the problem is due to security restrictions preventing you from accessing your asset files. lime run gets around this by starting an HTTP server, serving all the files at once as a website would do. If you want to test without lime run, you can use Python to start a server manually.

joshtynjala commented 1 year ago

Odds are, the problem is due to security restrictions preventing you from accessing your asset files.

Yeah, Lime/OpenFL pretty much always needs to be run from a server. You can't open the .html file from your hard drive because web browsers are really strict about accessing local files (images, etc.) and things. Back in the day, there wasn't much difference between local vs server, but at some point, browser vendors really locked things down for local files.

I want to deploy the app to a website and I don't want users to run into this issue.

It sounds like you'll be deploying to a server, so you shouldn't run into this issue.