A tax-free scholarship is not an "expense," so it's not the same as matching up the payment of a qualified education expense with the 529 distribution that funded or reimbursed that payment. Personally, I'm not worried about taking a 529 distribution even several years after a scholarship is received and still claiming waiver of the 10% additional tax for an amount of the distribution that equals the scholarship.
To make the AOTC scenario simple, just pay the qualified expenses when they are due with a 529 distribution that was taken in the same year, and then at tax time declare $4,000 of the distribution that was used to pay AOTC qualified expenses to be non-qualified, pay the tax on the earnings portion of that $4,000 (but not any 10% additional tax), and use the $4,000 to claim the AOTC.