Well, first of all, you can't use one global variable if you have multiple balls - they all have different reflection angles.
Also, with balls moving that fast you have to use stepping. Take a look:
dropbox.com/s/ei029r65pysf4hj/ballBounceTest.c3p
It works better, but balls can pass through corners of red squares. It's because the ray is cast from the center and misses the square. You'll probably need to cast two more rays (blue lines):
I think it will be easier to use Physics here. Set "Bullet=yes" and "Collision mask=Circle" in Physics properties and you should get perfectly bouncing balls.