The betatron effect in collapsing magnetic traps