How to dispose Tilemap?

When I want to resize the Tilemap, I do:

// try to dispose the tilemap:
if (tilemap!= null){
removeChild(tilemap);
tilemap.removeTiles();
}
// create a new one with new width and height:
tilemap = new Tilemap(new_width, new_height, tilesheet);
addChild(tilemap);

However, I’ve noticed that the old tilemap will not get removed from memory, and things get slower.

So, how to dispose tilemap correctly?

You can resize using tilemap.width = newWidth; tilemap.height = newHeight;

This will probably work better than dumping and creating a new one

thanks, but how would I dispose a tilemap?

I don’t think you have to do anything special, most of the memory is found in the tileset

It’s a pitty that HaxeDevelop 5.3.3.1 doesn’t recognize that useful parameter.
I wonder why is that happening? And i’m also wondering if it is happening as well with other IDEs.

What parameter is not appearing for you?

Is it listed on the OpenFL API documentation pages?

https://api.openfl.org/openfl/display/Tilemap.html

I don’t see neither height nor width, these are the ones I get while autocompletion is open in HaxeDevelop.

40gHnOpcVv tR9fNrWy1j Jv7sUipsoG

As I have seen they are referenced as DisplayObject Variables but not directly Tilemap variables.

Perhaps HaxeDevelop is tripping over the declaration in Tilemap.hx

We extend Bitmap on Flash Player since DisplayObject cannot be directly extended there. However this is more of an internal implementation detail and not intended as a part of the API