A Hamiltonian approach is introduced in order to address some severe problems associated with the physical description of the dynamical Casimir effect at all times. For simplicity, the case of a neutral scalar field in a one-dimensional cavity with partially transmitting mirrors (an essential proviso) is considered, but the method can be extended to fields of any kind and higher dimensions. The motional force calculated in our approach contains a reactive term -proportional to the mirrors' acceleration -which is fundamental in order to obtain (quasi)particles with a positive energy all the time during the movement of the mirrors-while always satisfying the energy conservation law. Comparisons with other approaches and a careful analysis of the interrelations among the different results previously obtained in the literature are carried out. . Here we will be interested in the production of the particles and their possible energy all the time while the mirrors are moving. In the case of a single, perfectly reflecting mirror, the number of produced particles as well as their energy diverge while the mirror moves. Several renormalization prescriptions have been used in order to obtain a welldefined energy; however, for some trajectories this finite energy is not a positive quantity and cannot be identified with the energy of the produced particles (see, e.g., [7]).Our approach relies on two basic ingredients: proper use of a Hamiltonian method and the consideration of partially transmitting mirrors, which become transparent to very high frequencies. We shall prove, in this way, both that the number of created particles is finite and also that their energy is always positive for the whole trajectory corresponding to the mirrors' displacement. We will also calculate the radiation-reaction force that acts on the mirrors owing to the emission and absorption of particles, which is related with the field's energy through the energy conservation law, so that the energy of the field at any time t is equal, with opposite sign, to the work performed by the reaction force up to time t [8,9]. Such force is usually split into two parts [10,11]: a dissipative force whose work equals minus the energy of the particles that remain [8], and a reactive force vanishing when the mirrors return to rest. We will show that the radiation-reaction force calculated from the Hamiltonian approach for partially transmitting