The first time
It sat on a shelf for seven years.
"That is when a logical person would stop and say, 'OK, this one didn't work out,' "the "How I Met Your Mother" actor told an audience of about 140 people from a stage Sunday at the Los Angeles Times Festival of Books on Sunday.
When the script became available again, Segel realized as its creator, he was the only person who would fight for it.
So he bought it back, and with the help of "The Eternal Ones" author Kirsten Miller, turned it into the first book of a trilogy.
Segel said there's this myth that people have to "wait for permission" before living out their dreams.
"If we're all very honest, there's this feeling we have that we're meant for more, that there must be more than this," Segel said, mentioning the wildly successful "Harry Potter" books. "There's this fantasy that someone is going to show up and be like 'No, no, there's a mistake. You're magic.' "
The screenwriter and actor said he attributes much of his success to his willingness to try new things without being afraid of failure or mediocrity.
Inspired by his childhood favorites, fantasies like Roald Dahl's "James and the Giant Peach" and "Labyrinth," Segel said he wanted to write a book that showed children that it's OK to be afraid.
"Nightmares!" is a book about a boy who is convinced that his stepmother is a witch and dreams of witches coming into his bedroom, trying to eat his toes. (Segel said he thinks this real childhood dream likely came from moments when adults pretended to eat his toes as a baby. "It's terrifying!" he said).
In the book, the witches come into what he thinks are his dreams. But when the boy wakes up, his brother is gone into a nightmare world.
The book centers on the adventure the protagonist embarks on with his three friends to save his brother. Along the way they face their biggest fears, he said.
"I've always felt like your fears are the gateways to your dreams," Segel said. "It's walking through them that you get to have these really great experience … that make you strong."
As an actor whose life is under a public magnifying glass, Segel said he had to come to terms with the fact that not everyone would like what he does and that all that mattered to him was that he tried.
"I'm a little bit afraid when he [the announcer] says 'HIMYM' [in introducing Segel], and I have to walk out here," Segel said. "It's a scary thing, but I'll be really happy when I walk out of here this afternoon, I think."
Segel commended Pixar Animation Studios for not shying away from heavier emotional subject matters in its movies aimed at children.
"They treat children like they're capable," Segel said. "Like the beginning of 'Up,' it's so intense. Man, I watched that, and I was thinking, 'Are you kidding me?' and then it really hit me. You treat a kid like they're really capable and can handle complicated feelings."
In the book, someone has created a tonic that will bring an end to nightmares but also, dreams.
"I think that your fears are, basically, you're scared that your dreams won't come true," Segel said. "(The book) raises the question of what is a world without fear because in my mind, without fear, there's nothing to hope for."
The second book of Segel's "Nightmares!" trilogy will be released this year.
Check out the Festival of Books schedule for this weekend.
MORE FROM THE FESTIVAL OF BOOKS: