After a disastrous spring, Mattel said it would cut nearly a quarter of its staff and sell some of its factories.

Mattel blamed the Toys "R" Us bankruptcy for the bulk of its problems. When the toy store mega-chain stopped buying new toys, Mattel lost its most important conduit to customers.

Sales fell 11% between April and June. Revenue would have been close to flat, though still down, if Toys "R" Us hadn't gone bankrupt, Mattel said.

Bright spots were few: Barbie sales grew 12%, and Hot Wheels sales were up 21%. Enchantimals and "Jurassic World" toys sold well too. That's about it.

Sales of "Cars" movie themed toys, Fisher-Price, Thomas & Friends and Toy Box toys were particularly awful last quarter. American Girl doll sales tumbled 32%. "Monster High" and "Mega" toys stunk too.

As if that weren't bad enough, Mattel had to compete with higher materials costs as the price of oil and other commodities soared. Sales in China fell as the economy slowed. So Mattel's profit margin fell sharply from 41% to 30%.

To save money and refocus the company on what's working, Mattel said Wednesday that it's firing more than 2,200 employees, or 22% of its workforce. It said it would close all of its factories in Mexico.

The vast majority of the layoffs are back-office and support roles, the company said. On a conference call with analysts, Mattel CEO Ynon Kreiz said the company performed a comprehensive "bottom-up review" to preserve the company's sales-generating and creative capabilities. He said he hopes the company can realign resources toward high-performing toys, improving online sales and developing better toy franchises for the future.

"We see a lot of opportunities, but there has been a big discrepancy between our financial performance over the last few years and where the company should be," Kriez said.

Kreiz was named chief executive in April. He took over for Margo Georgiadis, who held the top spot at the struggling toymaker for just over a year.

The company has long been rumored to be a Hasbro takeover target. Hasbro is the much healthier of America's two leading toy brands.

Mattel's (MAT) stock fell 9% in after-hours trading.