Help with Flashing Rectangle

Hi,

I am trying to insert two rectangles (flashMSWSing1 and flashMSWSing2) that flash on the screen. flashMSWSing1 is supposed to display when soundMSWSing is finished (this part works) and display for 0.1 second. I then wanted flashMSWSing2 to portray 0.05 seconds after flashMSWSing1 is displayed. I’ve inserted the following code but it only portrays one rectangle. The order of the components is: flashMSWSing1 then code then flashMSWSing2. Ive tried moving code to before 1 and after 2 but it still doesnt work.

Begin Routine:
myClock = core.Clock()
soundFinished = False
flash2Started = False
flash1Shown = False
flash2Shown = False

Durations

flash1Duration = 0.05 # duration for flashMSWSing1
flash2Duration = 0.05 # duration for flashMSWSing2

Each frame:

Check if the sound has finished

if not soundFinished and soundMSWSing.status == FINISHED:
# If sound has finished, display flashMSWSing1 and start the clock
soundFinished = True
flashMSWSing1.setAutoDraw(True)
myClock.reset() # Reset the clock to measure 0.05 seconds
flash1Shown = True

If flashMSWSing1 is displayed, check the clock

if flash1Shown and myClock.getTime() >= flash1Duration and not flash2Started:
# Turn off flashMSWSing1
flashMSWSing1.setAutoDraw(False)
# After 0.05 seconds, display flashMSWSing2 and start the clock again
flashMSWSing2.setAutoDraw(True)
myClock.reset() # Reset the clock for flashMSWSing2 duration
flash2Started = True
flash2Shown = True

Turn off flashMSWSing2 after its duration

if flash2Shown and myClock.getTime() >= flash2Duration:
flashMSWSing2.setAutoDraw(False)

End routine:

Check if the sound has finished

if not soundFinished and soundMSWSing.status == FINISHED:
# If sound has finished, display flashMSWSing1 and start the clock
soundFinished = True
flashMSWSing1.setAutoDraw(True)
myClock.reset() # Reset the clock to measure 0.05 seconds
flash1Shown = True

If flashMSWSing1 is displayed, check the clock

if flash1Shown and myClock.getTime() >= flash1Duration and not flash2Started:
# Turn off flashMSWSing1
flashMSWSing1.setAutoDraw(False)
# After 0.05 seconds, display flashMSWSing2 and start the clock again
flashMSWSing2.setAutoDraw(True)
myClock.reset() # Reset the clock for flashMSWSing2 duration
flash2Started = True
flash2Shown = True

Turn off flashMSWSing2 after its duration

if flash2Shown and myClock.getTime() >= flash2Duration:
flashMSWSing2.setAutoDraw(False)