There are few writers (if any) in Hollywood who’ve written for both Oliver Stone and Adam Sandler, and there is certainly only one who’s spent time over the last year scripting movies as different as a Miley Cyrus vehicle (So Undercover), an action remake (Escape From New York), and a hair-rock musical (Rock of Ages). “You could not get more diverse,” acknowledges Allan Loeb.

In an industry where most writers toil for years without having one of their scripts produced — and Loeb spent years as that sort of writer — he’s had four credited productions hit screens in the last six months (including the new Adam Sandler comedy Just Go With It), and his name comes up for seemingly every movie in town, no matter the genre. “At any given time, I’ll have five to ten projects in my orbit that are actively moving forward,” says Loeb. “But also at any given time, I’ll be focused on two or three scripts that I’m actually writing on, if that makes sense … It’s my job — and it’s a very high-pressure job — to get a script to the point where the Oliver Stones or the Robert Luketics or the Ron Howards of the world say yes.”

How did Loeb get so hot? It wasn’t supposed to be this way.

The 40-year-old grew up in Illinois with no intention of getting into film and originally pursued a career at the Chicago Board and Trade — “It’s kind of one of the things you do in Chicago” — until a screenwriter friend in Los Angeles began asking him for notes on his scripts. Impressed by Loeb’s story sense, he encouraged Loeb to come west and give it a try himself, and though Loeb occasionally found work, none of his films were ever produced. Eventually, those frustrations (coupled with a lifelong gambling addiction) took a toll, and Loeb began to mull leaving the industry to become a stockbroker.

“[I was] the baby writer at the lowest rung within the system, who has just enough rope to hang himself,” he says. “That’s what I lived and breathed for seven, eight years. The money’s not much, the respect is bad, and it’s tough to play in the minor leagues. I really was trying to find a way out.”

In 2004, after his agent called to drop him, Loeb finished his last-chance screenplay: The Only Living Boy in New York, a coming-of-age tale about a young man who falls for his father’s mistress. The well-received script sold to Sony and landed him a fourth-place spot in 2005 on the first edition of the Black List, a now-annual industry survey of the town’s best unproduced scripts. Still, there was even better news: His script for Things We Lost in the Fire took the No. 1 spot on the list, over Diablo Cody’s Oscar-winning Juno screenplay.

“I was the rookie of the year in the first rookie of the year competition, if you will,” he says. “At the time, it was quite surreal, because I’d been doing it for so long and had faced so much rejection. These were the same people who had been very hard to crack for me, so to get validation from these people seemingly overnight was a surreal situation. It was indescribable, I still look back in wonder.”

His act cleaned up after joining Gamblers Anonymous, Loeb ascended up the Hollywood ladder using the rungs that had eluded him for so long. Things We Lost in the Fire was produced in 2007 with Halle Berry and Benicio Del Toro as the leads (Loeb based the Del Toro character, a recovering drug addict, on his own struggles with compulsive gambling), and the card-counting drama 21 became a sleeper hit the next year. With those in the can, Loeb was now meeting with directors like Oliver Stone (for whom he scripted Wall Street: Money Never Sleeps) and Ron Howard, who hired him to write the Vince Vaughn–Kevin James comedy The Dilemma.

While most in-demand screenwriters specialize in one sort of movie (you hire Steve Zaillian for your prestige drama, Richard LaGravenese for your women’s picture, and Don Roos to rewrite your romantic comedy), Loeb credits his genre-hopping to good relationships. “When [New Line] came to me on Escape From New York and it was a good experience for all, they came right back to me, literally a week after I handed it in, and said, ‘Would you like to try a musical?’ And I said, ‘I’d love to try a musical. I’ve never done that.’ Credit to them that they weren’t so shortsighted to say, ‘He did Escape and that’s all he can do, so let’s go to the musical guy for the musical’ … It’s harder in this day and age of specialization to work in a lot of genres, but I’ve been fortunate enough to find a way to get Things We Lost in the Fire made and at the same time, power through The Switch.”

Still, it hasn’t all been smooth sailing. Films like The Switch, which Loeb adapted from a New Yorker short story by Jeffrey Eugenides, have met with mixed reviews, and The Dilemma was hit with controversy when its trailer opened with a Vince Vaughn riff on how electric cars were “gay.” (The line was pulled from the trailer, but remained in the film.) “I understand where the criticism is coming from. I was very surprised by it, though,” Loeb said, noting that plenty of other films walked The Dilemma’s line of political incorrectness and got away with it. “I don’t want to speak to it too much, but I’ve been blown away by the amount of times I’ve seen, since then, movies like The Hangover, The 40-Year-Old Virgin, episodes of 30 Rock, where it’s used in the same way, if not worse. I think the big mistake with The Dilemma is that they somehow put it in the trailer. If that line weren’t in the trailer, I don’t think it would have been such a big deal, because that word being used in that fashion has been used all over in movies, and no one’s had a problem with it until somehow it ended up in our trailer.”

Loeb is sanguine about the film’s reception, and he’s even relaxed his stance on something that used to frustrate him as an industry novice: rewriting other writers. Then, Loeb’s scripts would be handed over to another writer for additional drafts (and it still occasionally happens — on Just Go With It, Adam Sandler had a final pass on Loeb’s screenplay), but now, Loeb finds himself in the position of doctoring other people’s works. He says it’s given him a new perspective on how Hollywood runs.

“If the draft that the studio’s currently developing can get a movie star and an A-list director and a green light from the studio head, that script will do so, no matter who’s the writer,” he promises. “And many times it has, if you look at Juno, or even some of my own scripts, where a baby writer got it to the finish line. Ninety-nine percent of the time, though, it’s not that way. The draft will peter out, and it will not get the movie star or director they wanted, or the director they needed. So what do they do? They have to go to another writer, it’s just the process. They hope that another writer can take the script to the next level, and that’s also why they come to me: They will have a draft that they believe is good, that hits the mark, but they’ve taken it out to the top the directors in town and they’ve all passed. So they can either kill the script or they can come to me and say, ‘We really need to snag an A-list director. What would you do to take this from the 30-yard line to the goal line so we can get that director?’”

Loeb can even sympathize for the agent who dropped him just before he became successful. “You should never take it personal in this business, you have to understand where they’re coming from,” he says. “At the time, I was a client of his that wasn’t making any money for him or for myself, and it was probably time to drop me. Everyone’s trying to navigate very treacherous, competitive waters. A lot of times that means you’re going to be taken off a project or they’re not going to buy your script or they’re not going to make your movie or keep you on as a client. Whenever those choices are made, they’re not personal. That’s key. I had to learn not to take it personally and just keep going.”

Still, isn’t there a tiny bit of Loeb that wants to call up that agent and say, “I told you so”?

“He actually called me right after Only Living Boy in New York sold and congratulated me and kind of admitted that he might have made a mistake.” Loeb laughs. “I thought it was a very classy call.”