Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the latest Haxe (2.10), NME (3.4.3), and MUnit.

I've written some unit tests that need to fetch bitmap data from SWF symbols. The first step is to actually load the SWF data. To do this, I use NME's getByteArray along with the swf library, like so:

var blah:SWF = new SWF(Assets.getBytes("assets/swf/test.swf"));

The call to Assets.getBytes returns null when I'm running this under MUnit. When running my actual game code, I'm able to get the byte array (and consequentially, instantiate the SWF class).

Am I doing something wrong? What am I missing?

Edit: My directory structure is:

. (root
.\assets\*.png (other images)
.\assets\swf\*.swf (SWFs)
.\Source\*.hx (source code)
.\Test\*.hx (tests)
share|improve this question
I've not used any of those things, but it would seem returning null means it's unable to find the file specified. Check the path? – Byte56 Sep 19 '12 at 15:32
@Byte56 the path is impeccable, since the production/game code can find the file. Both sets of code are in the same "JAR" (java anology) or "DLL" (C# analogy). – ashes999 Sep 19 '12 at 15:52
What's the resulting directory structure? Is assets in a common directory or is it under the main directory? Is this the only file you have an issue with or is it all the files in assets? I'm still betting it's a path issue... – Byte56 Sep 19 '12 at 16:56
@Byte56 the resulting directory structure is mentioned above. Assets is a common directory. I only have issues with calls to getBytes; for example, I can call getBitmapData and getFonts without anyh problems from tests. – ashes999 Sep 19 '12 at 18:05

This looks like an issue with the working directory; likely when running under MUnit, your working directory isn't the same as when running your primarily applicable and thus the paths do not correctly resolve (it's also possible for some reason that file IO methods are disallowed under test, but that seems egregious).

Consider using embedding the resources in your test assemblies, or determining how to alter the working directory for MUnit's test execution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.