Here, I've set up a simple box that is weight painted so the main bone only influences the flap. The tip bone is there for the IK setup.(not sure I did this entirely right since I'm still just learning this as well)
Anyways, here are a few pics. First you can add a loopcut to the edge of the flap to limit the weight paint so the bone does not affect the rest of the box.

Now the weight paint setup.

There is an Empty added near the tip of the IK controller bone which is referenced in the IK constriant which I added to that bone as shown next.

I also added rotation locks to both bones so they can only move in one axis. The image shows 2 places where this can be done.

Next is an animation showing the result of moving the Empty.
