For optimization, change the zindex of the frame. This layer the images on top of each other to solve the flickering because while redrawing the last frame is still visible.
Keep incrementing the zindex value of the latest frame.
Note − You need to reset the zindex again, and it may have an amazing force on cutting down the flickering.