That's quite simple. You just need one layer on top of everything with a rectangle completely filled white or black. The white one would be switched visible for one frame, then invisible for several frames. Repeat. The black one would act the opposite way: invisble for one frame, blocking everything for several.