The Magnetic Field of a Contracting Gas Cloud: I. Strict Flux-freezing