How to correct destroy objects created by lime on web page?

On the page I have DIV

<div id="openfl-content"></div>

and script with embed()

lime.embed ("module", "openfl-content"...

i need to remove content in div “openfl-content” and remove any resources loaded by runing this script (all assets: images, sounds, … ) without reloading page.
How to do this?

I apologize that this feature has been overlooked

There is a System.exit command which is implemented for native but I believe it may be a non-op on HTML5. Ordinarily this would dispatch an exit event internally which can notify everything to remove event listeners and get ready for an exit.

What is the use case? I can imagine but I’m curious

Thanks :slight_smile:

EDIT: It should be easier to do using the NPM version of OpenFL because the Stage itself is something that is initialized by the user and so can be destroyed more easily, but I’d like to see this come to any version

Thanks for answer!
My case is a container of small games, which must be loaded/unloaded at one html-page.
All works perferct except memory - its never cleared, so 10-20 reloading games and memory overflowed…
I think it’s not hard to make destructor for lime object and its childs, but what to do to destroy WebGL context? even if unload any textures and clear all buffers of webgl context - javascript object still alive and no one method to kill it… And browser have small limit (16 contexts per page)
i see two ways to solve my case
1 use iframe but i don’t want it - it has another bad cases…
2 allow lime use existing webgl context instead of creating new

Actually you can use lime.embed with an existing canvas element as the target instead of a DIV

This means that you will need to size the canvas accordingly but (I presume!) this means you can re-use the same canvas between embeds in order to only initialize GL once :slight_smile: