In this study, the authors propose a new algorithm for the flocking problem of multi-agent systems with the dynamic virtual leader under the sampled-data frameworks. A necessary time-varying condition is derived on the sampling period for preserving connectivity of the network and avoiding collision among agents. Then, defining a new energy function, it is proved that using a connectivity-preserving potential function and under the sampling period which satisfies the necessary condition, an asymptotic flocking motion is achievable. Under the proposed sampled-data flocking algorithm, the connectivity preservation of the network and collision avoidance among agents are guaranteed as well as the velocity convergence of all agents to that of the virtual leader is ensured. Moreover, employing the upper bound of the energy function, they specify an upper bound of the sampling period which could satisfy the time-varying necessary condition. Finally, they present a numerical simulation to illustrate the theoretical results.