In February 2007, Allan Loeb went on a six-day bender and holed up in a suite in one of Las Vegas’s finest hotels, the Wynn. It was reminiscent of so many sleepless nights before, when Loeb, a compulsive gambler, had gone through bouts of betting thousands of dollars on football games. “Some weekends I’d win or lose twenty, thirty, forty thousand,” says the 38-year-old, whose lowest point came when he had to sell his Jaguar to pay the rent. “In L.A., living without a car sucked. I took the bus for two years.”

This bender, however, was different. The Hollywood screenwriter had less than a week to rewrite a script called 21, based on Ben Mezrich’s New York Times bestseller Bringing Down the House, about a group of MIT students who turn to card counting in Vegas to pay for medical school. An executive at Sony had hesitantly offered Loeb the gig and asked him to work his personal struggles, and the right vernacular, into the script. “He said, ‘Look, I don’t want to bring up a bad subject, but I heard a rumor that you were a big gambler …. Is it rude of me to ask you to take a look at [the script] to possibly work on it?'” Loeb accepted, despite having to spend some time in Vegas—a city he swore off after quitting gambling in 2004. “The irony is,” he says, “Hollywood’s the only business in which an addiction—or a negative-actually gets you work.”

Produced by Kevin Spacey and starring Kate Bosworth and Jim Sturgess, 21 lands in theatres on March 28th. Over chopped liver and matzo ball soup at Eleven City Diner (owned by his Highland Park High School classmate Brad Rubin), Loeb says that finding his way in Hollywood—as both a screenwriter and a producer—has helped temper his gambling impulses. “I was making so much money, I wasn’t tempted to relapse,” Loeb says.

In 2006, the L.A. Times called Loeb “screenwriting’s equivalent of the ‘It Boy'” after his screenplays for The Only Living Boy in New York and Things We Lost in the Fire turned up on the anonymously compiled industry Black List, which singles out insiders’ favorite works of the year. “Most writers tend to be introverted and most producers tend to be extroverted,” Loeb says. “I’m fortunate to be ambidextrous”—meaning that he also co-owns a production company with his longtime friend Steven Pearl, a Glencoe native. (Their company, Scarlet Fire Entertainment, borrows its name from songs by the Grateful Dead, a band that the pair have seen, between them, for a combined 300 shows.) So far, the producing partners have sold several films and TV shows, including New Amsterdam, about a New York homicide detective who is immortal (and a recovering alcoholic). When it premieres March 4th on Fox, it will have one of the most coveted weekly time slots in prime time, following House.

Last fall, Scarlet Fire did double duty: Pearl was in Chicago filming the pilot for The Beast, a gritty Chicago-based FBI show for Sony TV and A&E that stars Patrick Swayze in his first small-screen role, while Loeb tended to their buddy comedy for ABC called The More Things Change. (Neither show has been picked up yet.) The latter is perhaps Loeb’s most personal project yet, a TV show based on his male friendships from growing up on the North Shore. “Highland Park is a very unique place: People stay friends their whole lives,” he says. This network, which Loeb calls “the Highland Park connection,” has done more than fuel scripts; it has opened doors. On 21, Loeb worked closely with Highland Park native Doug Belgrade, a producer at Sony. And on last year’s Things We Lost in the Fire (which starred Halle Berry and Benicio del Toro), he worked with Adam Goodman, a Highland Parker and executive at Dreamworks.

“Allan’s really good at exploring relationships,” says Pearl, 44, a New Trier grad, “—which is ironic, since he hasn’t dated anyone since I’ve known him.” An active, happy bachelor, Loeb is hesitant to dish about the girls he dates, but he admits to occasional outings with actresses. “It’s always fun going out with actresses because they’re nuts,” he says.

It’s hard to imagine, then, that it was some four years ago that Loeb was consumed by gambling and talking about moving back to Chicago to get into the mortgage business. “Addiction is an energy vacuum,” he says. “You only realize it when it’s done: how truly you were not living up to your potential”—and what success looks like when you finally do.

Photograph: Hayley Murphy