<library path="my-swf.swf" generate="true" /> does not work on flash target

I’ve reported the bug in the openfl/swf git repository, but to make it more visible to google (so others doesn’t have to waste time googling like I did) I’m posting it here as well.
Generating the classes for the “Export to Actionscript” elements, is not working when exporting for Flash.

This doesn’t work on flash target:

<library path="assets/swf/Assets.swf" preload="true" generate="true" />

Example:

class Main extends Sprite 
{
    private var swfData:MovieClip;

    public function new() 
    {
        super();

        swfData = new MainChild();  // This does not work on flash player
        swfData = Assets.getMovieClip ("Assets:assets.MainChild"); //This works on flash player

        addChild(swfData);

    }

}

I’ve made a simple test project so you can check what is happening:

Bug report:
https://github.com/openfl/swf/issues/48

A workaround:

class Main extends Sprite 
{
	#if flash
	private var swfData:MovieClip;
	#else
	private var swfData:MainChild;
	#end
	
	public function new() 
	{
		super();
		swfData = cast Assets.getMovieClip ("Assets:assets.MainChild");
		addChild(swfData.firstChild);
	}
}

Setting the html5 target on the top menu of flash develop, you enable the auto completion, and when you need debugging with breakpoints you build for Flash.

Fixed! Thank you for the sample test-case, realized it was due to the package name of your exported class. This wasn’t handled quite right for Flash :slight_smile:

It’s amazing how you answer and fix bugs in a couple of hours. I wonder if you work with OpenFL in your spare time or is your main job.

:wink: