Flow of control question

BlitzMax Forums/BlitzMax Beginners Area/Flow of control question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Graphics 800,600

While Not KeyHit(KEY_ESCAPE) 'Escape 
Cls
SetColor 127,0,0
DrawRect 200,200,800,100
Flip
Delay 2000
SetColor 200,10,10
DrawRect 0,0,800,100
Delay 2000
Flip

Wend
End


I have the above piece of code.I want the test program to be exited by pressing escape.I then want the program to:
draw a box
wait 2 seconds
draw another box
wait 2 seconds
more commands...

What seems to be the problem with my code as the second box only flashes briefly and pressing escape only works when the second box flashed on screen? Am I missing something about the sequential flow of control ? Thanks in advance.