I am having trouble playing sound assets in Haxe. I am able to import mp3s with swfmill
without error:
<?xml version="1.0" encoding="utf-8" ?>
<movie width="100" height="100">
<frame>
<library>
... other resources ...
<sound id="Shoot" import="shoot.mp3"/>
</library>
</frame>
</movie>
In my Main.hx
, I created a class called Shoot
which extends Movieclip
in the same way I used for my .png
resources. Then I use this class as follows:
var sound:MovieClip = new Shoot();
stage.addChild(sound);
sound.play();
But at runtime, when this code is executed, I get the error
"Error #2136: The SWF File <project swf> contains invalid data".
Any obvious mistakes I'm making in my swf xml file or haxe code? How can I debug this error further?
I finally managed to play sounds from the library by declaring them as Sounds (instead of MovieClips)
and you don't need to add them to the stage, just play it: