This work addresses the optimization of flexible multibody systems based on the dynamic response of the full system with large amplitude motions and elastic deflections. The simulation model involves a nonlinear finite element formulation, a time integration scheme and a sensitivity analysis and it can be efficiently exploited in an optimization loop. In particular, the paper focuses on the topology optimization of structural components embedded in multibody systems. Generally, topology optimization techniques consider that the structural component is isolated from the rest of the mechanism and use simplified quasi-static load cases to mimic the complex loadings in service. In contrast, we show that an optimization directly based on the dynamic response of the flexible multibody system leads to a more integrated approach. The method is applied to truss structural components. Each truss is represented by a separate structural universe of beams with a topology design variable attached to each one. A SIMP model (or a variant of the power law) is used to penalize intermediate densities. The optimization formulation is stated as the minimization of the mean compliance over a time period or as the minimization of the mean tip deflection during a given trajectory, subject to a volume constraint. In order to illustrate the benefits of the integrated design approach, the case of a two degrees-of-freedom robot arm is developed.