Lighthearted heist movies used to be a Hollywood staple, but except for the “Ocean’s Eleven” franchise they’ve declined in number in recent years. Here’s a new one, which also feeds into the contemporary anger against big-time Wall Street types who have plundered the life savings of ordinary folk for their own benefit. And it boasts a strong ensemble.

But “Tower Heist” proves to be distinctly uneven. Oddly enough, the preparatory half—the “tower,” if you will—is better than the “heist” part, if only because it contains most of the amusing lines. True, they’re interspersed with material about the “little people” and the bigwigs who take advantage of them that’s actually rather serious in tone, but they still work. When the actual robbery kicks in, though, the picture becomes an action comedy with an emphasis on action rather than comedy (perhaps inevitable, with Brett Ratner in the director’s chair), and though it tries to be clever, it actually gets increasingly implausible and rather dull. Still, the whole remains better than most recent Hollywood comedies—but that’s due more to the cast than the writing or direction. And to the fact that it eschews the gross-out vulgarity that has become nearly obligatory in studio comedies nowadays.

The picture is set in a posh high-rise in New York City simply termed The Tower. The building manager is punctilious Josh Kovaks (Ben Stiller), who sees that everything runs perfectly and is especially solicitous of Wall Street mogul Arthur Shaw (Alan Alda), who’s long lived in the penthouse. Shaw reciprocates by agreeing to invest the pension funds of the building’s workers for them.

Shaw, of course, turns out to be a Bernie Madoff type, and the workers’ retirement savings disappear with those of all Shaw’s other investors. Kovaks, who feels responsible, initially reacts by confronting Shaw and damaging his most prized possession—a red 1963 Ferrari that once belonged to Steve McQueen and now holds center stage in the guy’s suite. But when that gets him fired, he decides to retaliate by putting together a gang to rob the safe he believes Shaw had secretly installed in his pad to house his emergency nest egg.

The bumbling crew eventually includes former concierge Charlie (Casey Affleck), whose job performance was marred by anxiety over his wife’s pregnancy; short-term elevator operator Enrique (Michael Pena), whose clueless demeanor provides the occasion for numerous non-sequiturs; Odessa (Gabourey Sidbe), a maid with expertise in lock-busting and safe-cracking; clerk Iovenko (Nina Arianda), who spends most of her time studying for the bar exam; and close-to-retirement doorman Lester (Stephen McKinley Henderson), whose attempted suicide spurs Kovaks to plan the robbery. Outsiders added to the employees are Fitzhugh (Matthew Broderick), a failed Wall Street numbers-cruncher whom Kovaks treated kindly when he was being evicted, and Slide (Eddie Murphy), a loud-mouth street hustler that Kovaks recruits to provide general criminal knowledge and some preparatory training for his unseasoned gang.

The first half of “The Tower,” with Broderick and Pena in particular offering some charming, low-key verbal gaffes and Alda some real venom as the moneyed rat—as well as Tea Leoni providing some spark as the pretty FBI agent who naturally sympathizes with Kovaks and Murphy happily returning to the ranting bad-boy mode of his earlier career—goes best. It’s hardly inspired, and there are some real dead spots (often involving Stiller, whose role puts him in more serious mode than usual, limiting his use of his usual nervous shtick), but overall it’s pleasant, amusing stuff.

Unfortunately, the heist sequence itself is disappointing. That’s partially because the plan isn’t set out for us beforehand, so that we can understand how it’s meant to unfold. As a result, some of it remains utterly muddled. (How, for instance, did Kovaks arrange to get Shaw’s arraignment moved—at least on paper—to Thanksgiving Day, a big part of the scheme since the robbery is to be conducted against the hubbub of Macy’s parade?) But that doesn’t matter so much because the script opts to have the whole scheme turned upside down by a double-cross that leads to some ad-hoc reworking—and to a supremely silly development that necessitates hoisting Shaw’s Ferrari from the suite with a rooftop crane, a feat that frankly seems logistically impossible given a revelation about what the car’s made of. (It would, one thinks, be far too heavy for even a small army of men to move, let alone two or three, though with Broderick liberating a red sports car, the homage to “Ferris Bueller” is a nice touch.) And the final twist that gives the villain his comeuppance is ridiculously thin.

Despite the letdown in the second half, however, the actors bring enough good humor to the party that you’re willing to overlook the flubs while appreciating the picture’s refusal to descend to gutter humor to the very end. It’s also handsomely mounted, both in the plush interiors and the external sequences, where Ratner shows off his technical skill at choreographing big action moments. So while “Tower Heist” never reaches comedic heights, the cast offers enough incidental pleasures along the way to make it an amiable, if inconsequential, ride.