Can't access GIF with Assets.getBytes

I’m trying to integrate a GIF into HaxeFlixel, to get around the issue of maximum texture sizes (eg. 1024x768) for large animations (not video). You can read about it in this HaxeFlixel issue.

I’m looking at using the haxe-gif library for this. From his instructions:

class Main extends Sprite { 
    public function new () {        
        super ();
        var bytes:Bytes = Bytes.ofString(Assets.getText("images/anim1.gif"));
        var gif1=new AnimatedGif(bytes);

Assets.getText and Assets.getBytes are returning null for the gif; even when I have explicitly included *.gif in the assets tag. Oddly, I can access assets/images/test.txt, so I know I’m using paths correctly.

Am I missing something?

The type of assets for gif file is probably not detected correctly,
try adding type="binary" to your <assets /> line in project.xml.

1 Like

@ibilon that resolved it, thanks.

Is there any way to verify the length (that it loaded the entire file)? I only see one or two frames play (if any).

Bytes have a length property you might want to check.
But it’s unlikely that a file was only partially loaded.

1 Like