Foam-Tac is a type of foam-safe contact cement that is designed specifically for foam. Manufactured by Beacon Adhesives. It stays flexible after its dry, so it can be used to make hinges but it also works really well for general construction. It can be used on balsa and carbon-fiber as well as foam, and has many other uses as well.
The large 2oz bottle is meant to be used quickly, since it will dry up if a partially-used bottle is left standing for many months. This product is also available in smaller 1-oz and “mini” 5ml squeeze tubes.