I converted my flash code to OpenFl, and it now run nicely in the Flash target. So the next step has been to make it compile in HTML5 as well.
However I now have some errors I do not know what to do with:
TypeError: ApplicationMain.config is null
pointing to these lines:
23631 "ApplicationMain.config.background = color;"
2390 “var assetsPrefix = ApplicationMain.config.assetsPrefix;”
I also have several of these errors:
SyntaxError: unreachable code after return statement
This are the libraries I am currently using:
openfl [3.2.2]
lime [2.5.2]
swf [1.8.9]
I would be happy to get help and tips on how to handle this.
If there is something in my code that is causing this I would also be happy to get tips on how to debug that, since I don’t get so much information from the browser console.
I don’t know if this is the case,
But I got this error several times before, and on all case closing all windows and restarting the IDE solved the problem.
I am using the openfl command to build it. And PiratePig works, so there is probably something wrong in my code then I assume.
Is there any tips on what could help to debug this?
Or any pointers to things that often causes these kind of problems?
Or anything else that could help making HTML5 debugging easier
I just installed everything over the weekend for the first time, so I should have just about the most up-to-date versions of everything:
OpenFL: 3.3.6
Lime: 2.6.6
Haxe: 3.2.0
I’m using FlashDevelop 5.0.1.3, I closed the IDE, then cleaned and rebuilt the project, with the same results. Smaller test projects work fine, so I assume that I too am doing something invalid in my code. I don’t believe I’m doing anything exotic, as I haven’t learned much about Haxe or OpenFL yet.
Exploring it a little bit, the first error was in code related to SharedObjects, so I commented out any reference to openfl.net.SharedObject in my code, and it looks like I was able to overcome whatever was happening. Is it possible there are bugs related to how these are handled in the HTML5 code? (I assume there’s a compatibility layer using cookies or something for these? I know very little about the HTML5 spec.)
@Sara, if you’re still around, does this solve your issue as well? Has anyone else had issues with openfl.net.SharedObject in HTML5 targets?
Could you post a build of your project somewhere that I could view? If its private, you could send a private message, but this might help to see it in action myself
I was about to send a PM, but then I found out the issue was related to the design pattern I was using for singletons. (A pattern that I admittedly was not fond of.) Here’s a small sample program that reproduces the issue:
package com.skoobalon.test;
import com.skoobalon.test.Main.MySingleton;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.net.SharedObject;
import openfl.errors.Error;
class Main extends Sprite {
public function new() {
super();
}
}
class MySingleton {
public static var instance(default, null):MySingleton = new MySingleton();
private var _so:SharedObject;
public function new() {
if (instance != null) {
throw new Error("Singleton class");
}
trace("Making a new singleton");
_so = SharedObject.getLocal("foo");
}
}
This code compiles fine and works in the Flash player, but does not work for HTML5. So I would surmise that the bug is in the generated HTML5 code. And I’m sure that a workaround can be concocted with little effort on my end. I fear that I don’t have time to investigate the OpenFL code myself to come up with a solution to this problem.