Updating fillrect

I have a simple rectangle as such in create:
graphics.fillRect(((minimap1.x) - 1163), ((minimap1.y) - 1037), health, 10);

How would I go about updating the health variable there without redrawing the entire rectangle each time? Redrawing the rectangle turned into a massive memory leak when I tried it that way.

You need to clear before redrawing.

Or use a Rectangle game object instead and just scale it.

Works wonderfully, thank you samme.