Barack Obama was much older than 8 when William Ayers was photographed stepping on a US flag in 2001, for an article in which Ayers said he had "No Regrets" for his violent actions in the Weather Underground.
In fact, at the same time Ayers was in a Chicago alley desecrating the flag, he and Barack Obama were serving on the board of the Woods Fund together: PolitiFact | Obama served on board with Ayers.
Deborah Harrington, president of the Woods Fund, a philanthropic organization in Chicago, said Obama was a director from 1994 through 2001. That overlaps Ayers' time as a director by three years. It also means Obama served with Ayers for the final months of 2001, after Ayers made his comments to the New York Times.