Porting a flash game to openfl

There were a project in flash which I wanted to port it in Openfl, in order to use its awesome features.
I didn’t write the project, and actually don’t know about the structure of flash.
I use this to convert “as” files to “hx”. Then I remove the compile errors by hand, and comment some part of code (that was about an external use of a swf file).
Then I press the “test project” button on FlashDevelop, which is the IDE I use for Openfl project, and the configuration is on “Debug” and “neko”, I get this error:
AL lib: (EE) alc_cleanup: 1 device not closed
What is this about?
Thanks for any help!

Have you tried running it in the terminal with the --verbose flag? Might give you a bit more information.

Can you give me the detailed command? I mean I never run it through terminal…

I’ve use a trace(“Hello world”) to debug it by my hand.
I found two lines of code, which initializing x and y of an object like this:
startbtn.x=stage.stageWidth/2;
I’ve comment those two, and the error disappeared.
Searching on the internet shows me the problem is about audio. in this case is not. so maybe there is more digging needed for finding the root of problem.
Thanks!

cd into your project and then run:

openfl test neko(Or whichever target you want) --verbose

Has startbtn been initialized before x is set?

You can also use the -debug flag, which may give you a stack trace when it crashes

The error message you got certainly is sound-related. However, it was caused by a different error that you didn’t see because you were using FlashDevelop rather than the command line. For whatever reason, FlashDevelop hides stack traces generated by Neko apps, even in debug mode.

If you run from the command line (even without -debug or --verbose), you’ll get a stack trace pointing you to the actual error. In your case, the error was a null pointer - stage was null, and you were trying to access stage.stageWidth.

To fix this sort of error, you have to wait until stage is not null. Generally, you use some code like this:

if(stage != null) {
    init();
} else {
    addEventListener(Event.ADDED_TO_STAGE, init);
}

This guarantees init() will be called as soon as you have a valid reference to stage. Now you can put the rest of your code in the init() function:

private function init(?e:Event):Void {
    startbtn.x = stage.stageWidth / 2;
    startbtn.y = stage.stageWidth / 2;
}