[SOLVED] HTML5 works in FireFox only


I’m new to OpenFl (I’m an AS3 refugee).

I have some problem with HTML5 target: my code works only in FireFox and not in Chrome, Opera or Internet Explorer.

Could somebody please take a look, because I don’t know where to start.
This is a very basic project with a white rectangle drawn on Stage:

xml file:

<?xml version="1.0" encoding="utf-8"?>
	<meta title="my_project" package="" version="1.0.0" company="OpenFL" />
	<app main="Main" path="Export" file="my_project" />
	<window width="800" height="600" fps="61" background="#333333"/>
	<source path="Source" />
	<haxelib name="openfl" />

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

hx file:


import flash.geom.Rectangle;
import flash.display.MovieClip;
import openfl.display.Sprite;
import openfl.Lib;

class My_class extends Sprite {   

	var  engine_container:MovieClip = new MovieClip();

public function new () {   


	public function init() {

		engine_container.graphics.drawRect(30, 30, 100, 100);

		Lib.current.addChild( engine_container ); 


I just recreated your sample and in runs flawlessly in IE11 and Chrome 60.
Do you receive any error messages in the console? (CTRL+SHIFT+I)
Also in case you’re using FlashDevelop it might be useful to clear your browser cache.

1 Like

Thanks for the response.

You were right - this is not a problem with openFl - the problem resides in browsers vs security policy. I changed the testing environment (from local to public server) and the project works fine.

So I will have to work a little on my local testing environment.


Are you using openfl test html5 to host your content, or did you open the generated “index.html” by hand?

Use openfl test html5 and then open “http://localhost:3000” in your browser, and it should help with most security problems, I believe :slight_smile:

To answer your question ‘singmajesty’: I open index.html by hand.

So I prepared my testing environment as follow:

I installed web server (Apache HTTP server) on Windows and change the directories in it’s config file from: “/htdocs” to “my_project/Export/html5/bin”

Now I test my openfl/html5 just by typing “localhost” in a browser.

Of course it is also possible to additionally configure Apache to prevent browsers from file catching (necessary for testing) or one can just use ctrl + F5 in a browser window (instead of normal refreshing)

You can also openfl test html5, if you want to… we have embedded a web server in our command-line tools, to help workaround security issues :slight_smile:

(we also have caching disabled in our server, definitely helpful while debugging :slight_smile: )

1 Like