Since this was for the flickering effect for a game (so the character being hit starts to flicker slowly and then flickers more quickly), I ended up making a solution based on @Blender answer.
The only difference is that apart from making the vertical bouncing separation smaller, it also makes the horizontal bouncing separation smaller.
The code in AS3 would be:
// flickerTime is a Number between 0 and max, in seconds.
// max is the amount in seconds that the flickering effect lasts
// 10 is a constant that can be changed if we want more or less flickers in that amount of time
var max:Number = 3;
var flick:Number = Math.cos(this.flickerTime * this.flickerTime * 10) * (max - this.flickerTime) / max;
this.visible = flick > 0;