We propose a novel direct transcription and solution method for solving nonlinear, continuous-time dynamic optimization problems. Instead of forcing the dynamic constraints to be satisfied only at a selected number of points as in direct collocation, the new approach alternates between minimizing and constraining the squared norm of the dynamic constraint residuals integrated along the whole solution trajectories. As a result, the method can 1) obtain solutions of higher accuracy for the same mesh compared to direct collocation methods, 2) enables a flexible trade-off between solution accuracy and optimality, 3) provides reliable solutions for challenging problems, including those with singular arcs and high-index differential algebraic equations.