Haxe Compiler Cannot Recognize OpenFL Imports

Hello -

For some reason, whenever I try and run my code with the Haxe compiler, it gives a message like “Type not found : openfl.display.Sprite”. If I remove the import statement for openfl.display.Sprite, the same thing happens with the next import, Sprite just happens to be first on my list. The strange part of this is the fact that I can still test my project from terminal, and it runs without issue (for example, I use terminal to type “openfl test neko” and it renders my stage). From what I’ve seen, everything else recognizes OpenFL, and it can run with no problems. I have no issue when I try importing a Haxe standard library, such as Std.int.

To troubleshoot, I’ve looked through the project.xml file, found the source of my OpenFL library, and tried reinstalling both Haxe and OpenFL. Nothing seems to be wrong in any of those fields.

As for my import code, I’m fairly certain it is all correct:

import Std.int;
import openfl.display.Sprite;
import openfl.display.Tile;
import openfl.display.Tilemap;
import openfl.display.Tileset;
import openfl.geom.Rectangle;
import openfl.utils.Assets;
import openfl.events.Event;

I’m just trying to get this solved so I can trace my code and track values as my code gets more and more complex. Thanks for any help.

What exactly do you mean by this? You normally don’t invoke the Haxe compiler directly directly in an OpenFL project, only indirectly through the OpenFL / Lime command line tools.

I’ve been using VSCode as my text editor (With required Haxe and Lime extensions), and whenever I run the code, I get the error I described. I’m fairly certain that the command it uses to do so is haxe --cwd “/Users/myname/Desktop/SimpleTilemap/Source” --run Main. Even outside of VSCode, running the Haxe command on my project doesn’t recognize the import statements importing OpenFL packages.

The reason I want to do this is to use the Haxe trace() function in order to debug.

How are you “running the code”? Are you by chance using the Code Runner extension? If so, that’s really only meant for standalone scripts / files.

Try using the Lime extension’s tasks (Terminal -> Run Task…).

I do in fact have that installed, though I didn’t think that was a problem because the command line didn’t work either (using the command in my previous reply). When I did Command+Shift+B and did “lime: build (active configuration)” my terminal window in VSCode said

Executing task: lime build html5 —connect 6000

Terminal will be reused by tasks, press any key to close it.

And nothing happens. I also tried doing this with the code runner extension disabled.

“Nothing happens” is the expected result here, that means the compilation was successful. :wink:

Use “test” instead of “build” to also run the application after compilation.

1 Like

That did the trick, thank you!