Pivoting an object with respect to two objects
I actually figured this problem out. I selected the cylinder. Entered into edit mode. Then selected the top vertices of the cylinder. I hit "CTRL H" and selected "Hook To New Object". This created an empty which I then parented to the floating grey box using "CTRL P". I deselected all and then selected the bottom vertices of the cylinder. I hooked these to a new object also which I parented to the blue box. This way if the blue or grey box moves the red cylinder is attached to both of them.