The gunman, armed with a semiautomatic AR-15 assault rifle, was a former student of the school who began his rampage shortly before dismissal time, the authorities said.