Can’t access GIF with Assets.getText


I have a very similar issue to this post Can't access GIF with Assets.getBytes but the fix proposed does not work for me… :frowning:
Basically, I want to display an animated gif using the haxe-gif library:

var bytes ="images/mygif.gif"));
addChild(new AnimatedGif(bytes).play());

But I got the following error:

There is no String Asset with an id of images/mygif.gif

Same error (no ByteArray asset) if I do:

var bytes ="images/mygif.gif"));
addChild(new AnimatedGif(bytes).play());

So I added the type “binary” to my assets tag in the project.xml file as suggested in the post mentioned above but I still got the same error.

<assets type="binary|images|text" path="../../Assets/img/hd" rename="images"/>

Any idea?

I don’t think you can have multiple type for an assets tag,
they are used to override the type inferred by the tool not choose what gets added.

Instead do something like this:
<assets type="binary" path="../../Assets/img/hd" rename="images" include="*.gif" />


Thank you, following your advice I can now load the gif. But the animation won’t play :(. I tried with 2 libraries, haxe-gif and yagp


var bytes ="images/mygif.gif"));
addChild(new AnimatedGif(bytes).play());


var gif:Gif = GifDecoder.parseByteArray(Assets.getBytes("binaries/" + src));
var player:GifPlayer = new GifPlayer(gif);
var wrapper:GifPlayerWrapper = new GifPlayerWrapper(player);

I got the same result for both: only the first frame is displayed and the animation does not run. I only target Flash and my gif size is 960x540 pixel.

I tried with different files and the animation is correctly played in a browser so the issue does not come from there… I join a very basic example.


这个bug已经解决了,需要的朋友可以参考下,已经推送上去了,但暂时没有合并 。

1 Like