Reputation:
I've a main Haxe script in a file called Main.hx. And in this same script I can import any existent package, including other Haxe scripts in the same directory that are considered package, but Haxe scripts (which should be considered package) that are declared in nested directories doesn't work with import
(I'm almost sure that they're being ignored).
Haxe is just sayin' that Test
doesn't exist. When I try to get wow.test.Test
it says the same thing, and same with test.Test
. I've also tried to set the package name at ./wow/test.hx
as wow.test
and test
, and it was the same situation.
It only works if I throw test.hx
outside of ./wow
and import its things normally, like: test.*
instead of wow.test.*
.
My test structure:
—— ./Main.hx ——
package;
import haxe.unit.TestCase;
import openfl.display.Sprite;
import native.*;
import wow.test.*;
class Main extends Sprite
{
public function new ()
{
super ();
new Test();
}
}
—— ./wow/test.hx ——
package;
class Test
{
public function new ()
{
trace("Dum !!");
}
}
Or would I need to configure that?
Upvotes: 1
Views: 911
Reputation: 46
Haxe packages are folders and the files they contain are called modules. A module can itself contain one or more types.
To quote the manual :
The (dot-)path to a type consists of the package, the module name and the type name. Its general form is pack1.pack2.packN.ModuleName.TypeName
There is two issues in your example :
test.hx
to Test.hx
, you will be able to import the type with import wow.Test.Test
. But since the module name and the type name are the same, you can omit the module name and just use import wow.Test
.package wow;
Upvotes: 2