In this paper, we develop a decentralized cooperative controller for a group of mobile agents, which consists of three elements: a bounded repulsive potential field, a bounded attractive potential field, and a velocity matching term. Two cases that flocking without a leader and with a leader are considered. Under some initial conditions, we prove that for both cases the control law not only can steer a group of agents to synchronization (a desired synchronization for the case with a leader), but also can avoid the collision as well as preserve the connectivity of the interactive network for all time. Some simulations are also done to show the efficiency of the controller.