How can i make a flashlight like the one in Realistic Rendering?

Hi, I’d like to make a flashlight like the one in the realistic rendering demo, where it sways and moves 0.5 seconds after your camera does and it looks realistic. How can i do that?

Umm…look at the Bp