Making an object disappear/reappear

I have been going through and making a simple point and click game as my first project. I have 4 gameObjects currently in use, 3 of which have their code set and ready to go. The last one i’m trying to work with needs to stay up on the screen for 3 seconds then disappear then reappear randomly in a random position. I can get it to disappear (simple right?) but everytime i try to make it reappear for X amount of seconds then disappear again it just keeps flashing really fast. Like its being rendered really fast constantly. Please help!

What my code looks like:

var blinkingSphereTimer : float = 3.0;

var blinkingSphere : boolean = true;

function BlinkingSphere ()
{

if (blinkingSphere)
{
	yield WaitForSeconds (blinkingSphereTimer);
	renderer.enabled = false;
}

}

if you’re using yield, it has to be a coroutine… I’m not exactly sure how to do that in javascript, but in C# you have to define the function as an IEnumerator.

try something like this

function BlinkingSphere () {
    while(blinkingSphere) {
        yield WaitForSeconds (blinkingSphereTimer);
        renderer.enabled = false;
        yield WaitForSeconds (blinkingSphereTimer);
        renderer.enabled = true;
    }
}

@Antony That does exactly what its been doing the entire time. Blinking rapidly instead of at a fixed rate.