Is there a way to access a specific frame of an animation/transition?

I would like to set an object active, when a specific frame of an animation is reached, and after 2 frames it shall disappear. Is there a way to access every single frame of an animation/transition? Something like

if (the animations frame == 21)
{
do stuff;
}

You can do exactly that using Animation events. Just set an event on the frame you want the object to become active and then set another event to make it disappear two frames later.