‘The Town': Ben Affleck, All Is Forgiven (Yes, Even J.Lo)

It turns out, Affleck had been paying attention all those years on set when he had chances to work with talented directors — and he was a lot smarter than he acted

Plenty of stars direct a movie. Once.

Usually these are passion projects with small budgets that barely get released. Anyone else sit through Nicholas Cage’s “Sonny,” Matt Dillon’s “Ghost City” or Gary Oldman’s “Nil by Mouth”?

Of course, they soon discover that directing a feature film eats up a year or two or more of their lives, while acting in a big studio movie just takes two or three months and offers a vastly fatter paycheck. Bye-bye, directing career.

Then there are actors who, once they step behind the camera, seem to the viewfinder born. Hello, Clint Eastwood, Ron Howard, George Clooney and Mel Gibson. They have an innate sense of storytelling, have an appreciation for moral complexities and ambiguities (well, at least the first three do), and are able to draw compelling performances from their actors.  With “The Town,” the second film he has directed, Ben Affleck joins this much smaller group.

In “The Town,” a crime thriller which he also co-wrote and stars in, Affleck plays the movie’s flawed hero, Doug MacRay. Born and raised in Charlestown — a white, working-class enclave in Boston where the most popular local trades are stealing cars and knocking over banks — Doug is trying to remake himself. The leader of a successful gang of bank robbers, he wants to leave behind his criminal ways, buddies and neighborhood. Easier wished for than done. Like Michael Corleone in “Godfather III,” he keeps getting pulled back in.

It’s clear why the material — it’s based on a 2004 novel, “Prince of Thieves,” by Chuck Hogan — attracted Affleck. It’s set in Boston, near where he grew up, and includes scenes at Fenway Park, where his beloved Red Sox play. Boston also was the locale for Affleck’s impressive maiden directing effort, “Gone Baby Gone,” a 2007 crime drama.

But more to the point, Affleck knows a little something about remaking one’s self and leaving the past behind. You don’t have to be Sigmund Freud to spot the obvious parallels between the movie’s protagonist’s longings and Affleck’s own.

Now 38, Affleck became a big star fast. There he was at age 25, sitting in the front row at the Oscars with best buddy Matt Damon, listening to their names being called for Best Screenplay for “Good Will Hunting,” in which they had co-starred. Big roles in big dumb movies followed.

As an actor, with a few noteworthy exceptions (such as “Changing Lanes”), Affleck has always been something of a big lug. Every time he lumbered on screen, one expected the soundtrack to start tinkling, “De-dum, de-dum, de-dum.”

Partly it was because, for a while there, he was playing lunkheaded action heroes in soulless, assembly-line, commercial crap like “Pearl Harbor,” “The Sum of All Fears” and “Daredevil.” You know that de rigueur shot where the movie’s protagonist dives toward us just ahead of the massive fireball: Affleck had that one down pat.

Soon, he started acting like a big star, and not just on screen. Cue the Ben and Jen tabloid headlines (Affleck and Jennifer Lopez, or Benifer to those who have forgotten their highly public engagement) and their two disastrous cinematic collaborations, “Gigli” and “Jersey Girl.” Then he became a national punchline and, like that, the career was over. Oh, he kept working, sort of, but no one paid much attention. Time to leave the past behind and reinvent himself.

It turns out, Affleck had been paying attention all those years on set when he had chances to work with talented directors. And he was a lot smarter than he acted.

What’s best about “The Town” is its gritty sense of place and the moral complexity of its characters. It’s not just Doug who is conflicted. Every single main character at some point crosses a moral line — Rebecca Hall plays a bank manager with whom Doug falls in love; Jon Hamm is an FBI agent who’s tracking Doug; and Jeremy Renner is Doug’s short-tempered childhood pal and fellow criminal. It is a credit to Affleck’s direction, and the talent of the performers here, that the shifting alliances and moral ambiguities are so clearly delineated.

“The Town” is not perfect. There’s one robbery and chase scene too many, and the ending strains a little too hard to be upbeat. These seem like calculated bows in the direction of Hollywood commercialism. This is, after all, a studio-made film (Warner Bros.) with a budget reported to be near $40 million.

But as commercial popular films go, “The Town” is a pretty darn good one. The characters draw you in and the story keeps moving.

Those comparisons some other reviewers are making to Clint Eastwood and Martin Scorsese may be a little premature, but Affleck is absolutely on the right path.

And this comes from a Yankees fan.