Note: If you want this to happen on a keypress or something else (instead of looping), just change the sensor.
Andrew Price's Tutorial on creating a flickering light: http://vimeo.com/9853432
This isn't the best tutorial, but I didn't have time to do more than one take. Hope this helps, and feel free to ask any questions you may have!