[SOLVED] Preloader for Flash target

Hi all,

I’m working on a Mac+Windows game in Haxe, and I’ve recently released the demo (check it out!). I think a good way to get more people to play it would be for it to be available in-browser, so as Flash. But I haven’t been able to find working directions for getting it working using the lime command.

  • I tried following the old way with the haxe command using the swf-preloader-frame and flash-use-stage arguments, but it created an original SWF without any assets, so that didn’t work. It seemed I couldn’t use my existing project.xml in the haxe command.
  • I tried using the SWF library to include the original SWF as a library, but I’m unable to compile. I get this error: “Class SDLApplication is implemented in both /usr/lib/haxe/lib/lime/2,0,6//legacy/ndll/Mac64/./lime.ndll and /usr/lib/haxe/lib/lime/2,0,6//ndll/Mac64/lime.ndll. One of the two will be used. Which one is undefined.” for SDLApplication, SDLAppDelegate, SDLTranslatorResponder, SDLMessageBoxPresenter, SDLOpenGLContext, SDLWindow, Cocoa_WindowListener, and SDLView. Even though I’m trying to build for Flash!
  • I tried to load the SWF using Assets.loadBytes but I keep getting an error in the Flash file that ‘There is no asset library named “”’

So I’m feeling a little stuck at the moment. Is there a way to do this anymore, or not currently? Preloading is a pretty universally-needed feature for Flash target, I believe.

OpenFL includes a preloader by default. If you want to change it, add this to your project.xml file:

<app preloader="com.themissiongame.Preloader" />

Then create the class:

package com.themissiongame;

class Preloader extends NMEPreloader {
    public function new() {
        super();
        
        removeChild(progress);
        removeChild(outline);
    }
    
    public override function onUpdate(bytesLoaded:Int, bytesTotal:Int):Void {
        //Draw something to show progress.
    }
}
1 Like

Normally a simple lime test flash should work, what error message do you get?

Openfl automatically adds a preloader, which you can customize, see this topic for an example [CLASS] OpenFL custom Preloader Example

1 Like

Thanks for the replies, they were super helpful! Of course OpenFL would have a preloader for Flash, I should have expected it :slight_smile:

So there is a problem later on, but I believe it’s unrelated so I’m going to start a new topic (if I can’t find a solution before then).

@singmajesty could this information on the NMEPreloader be added to the Flash documentation in the Learn section?