First, you make a ball (optionally 2). You will also need to make a variable (or two depending on how many balls you have). You set the variable to constantly changing depending on the coordinates of the ball. After that, you make the ball move by setting the coordinates of the ball to 0, 0. (Keep in mind, if you're making it go up and down, be sure to make it face up.) Later, you will make it go straight, and when it touches the wall, turn it 180 degrees and keep it going. (As you see here, I made it take 10 steps every 0.0001 seconds, if you want it to go more smoothly, you can make it go slower.) You will then need to make the item you want to flicker change color based on the X/Y of the ball (or 2). Finally, all you need to do is hide the ball (2). (Keep in mind, it can get pretty lag filled.)
As it turns out, you can hide the balls and still make the code work.