We demonstrate adaptive aberration correction for depth-induced spherical aberration in a multiphoton scanning microscope with a micromachined deformable mirror. Correction was made using a genetic learning algorithm with two-photon fluorescence intensity feedback to determine the desired shape for an adaptive mirror. For a 40x/0.6 NA long working distance objective, the axial scanning range was increased from 150 mm to 600 mm.