Transparent canvas in Starling Haxe for HTML5

Hi, I am facing the need to use a transparent OpenFL canvas when exporting for HTML5. this is quite simple to do when leveraging only OpenFL: Just declare background as null in the XML config and it works great.

But when using Starling, the canvas is always black. I tried to change the canvas background to transparent at runtime using Javascript but Starling is really only painting the parent ‘stage’ object or something like that. I’ll try to check the source code to find a way but in the meanwhile, maybe someone here could help me.

Thanks in advance. OpenFL is simply amazing and it was the only tool that I found reliable yet simple enough to perform what I need to do for a client.

Thanks for the kind words :slight_smile:

Please check your HTML template, are you sure that the default template is not the one setting the black color? This happened in a previous project I was testing for transparency – it was actually transparent, but the default HTML template set a black background color in the CSS for it’s parent DIV, making it look like it had a black background.

If not, then I believe there was a bug I fixed in Starling for supporting transparent backgrounds, it might be that your version needs to be updated (or I need to update the haxelib version)

Hey, it wasnt any css that was causing the problem. I just had to change stage.color to 0x000000 after the starling root sprite gets added to the stage. It is now working fine. Great!