"Ruby Sparks," With Zoe Kazan and Paul Dano Merrick Morton/Fox Searchlight Pictures Zoe Kazan and Paul Dano, in "Ruby Sparks." OUR capacity for fantasy - for indulging that nagging sense that as good as we've got it, there could be something better, some person or place that could transform us - might be humankind's greatest burden. That idea, and the flood of neuroses that follow when we eschew reality for an imaginative flight, is the central conceit behind "Ruby Sparks," a new film written by the actress Zoe Kazan and starring her real-life boyfriend, Paul Dano. Mr. Dano, left, and Ms. Kazan, right, with their directors, Jonathan Dayton and Valerie Faris, on the set. The 29-year-old Calvin, played by Mr. Dano, is a literary wunderkind who published an acclaimed novel at 19 but can't seem to produce a follow-up - until, in response to an assignment from his therapist, he conjures Ruby Sparks (played with heavy bangs and wide eyes by Ms. Kazan) and begins typing frantically. Then one morning Ruby appears in his foyer, wearing his shirt and eating a big bowl of cereal. From there "Ruby Sparks" indulges in a bit of magical realism, but the film also satirizes the devastating (and occasionally insurmountable) transition from an imagined relationship to a real one, a subject the two stars and their directors know well. The movie's circumstances might be preposterous, but "Ruby Sparks," being released Wednesday by Fox Searchlight, speaks to the universal pain of having to reconcile your dreams about someone with an actual person. For Ms. Kazan the capacity to distinguish between the two (and to opt actively for one over the other) is an early marker of adulthood. "You can't pick and choose a person," she said in a phone interview from Toronto, where she and Mr. Dano are promoting the movie. "It's not "choose your own adventure." You kind of have to take the whole package. And that's something that I've really felt in my relationship with Paul, and in other relationships. Loving someone wholly, loving someone for themselves, loving someone for all the parts of them is how you grow and become an adult person. Ms. Kazan and Mr. Dano, both 28, have been dating for five years and live together in Brooklyn. Although she has written for the stage, "Ruby Sparks" is Ms. Kazan's first screenplay, and while she didn't set out to write roles for herself and Mr. Dano, he quickly recognized the potential on the page. "I showed it to Paul, and he was like, "Oh, you're writing it for us?" " Ms. Kazan said. "As soon as he said it, I looked at the page and was like, "Oh, that's totally true." " Although the situation had its moments of metaphysical confusion - Ms. Kazan wrote Calvin, Calvin wrote Ruby, Mr. Dano and Ms. Kazan eventually became Calvin and Ruby - Mr. Dano said the life-art overlap was mostly contained. "For me the best thing that Zoe did was not write a film about our relationship or write us as characters," Mr. Dano said, also by phone. Calvin and Ruby are Calvin and Ruby, they're not Paul and Zoe. Luckily, when I watch the film, I'm not thinking about us. I don't see us. I don't see the girl I see in our apartment. I see Ruby. Not incidentally, "Ruby Sparks" was directed by a husband-and-wife team: Jonathan Dayton and Valerie Faris, who first worked with Mr. Dano on their 2006 comedy "Little Miss Sunshine." "We've always shied away from high-concept movies, but what we loved about this was that it had its magical elements, but they were treated in such a matter-of-fact way," Ms. Faris said in a phone interview. It didn't feel like a fantasy. She added: "There often isn't a clear delineation between the real version of the person you're in a relationship with and your fantasy of who they are. Those things are always blurry. In life in general it's hard to distinguish between what's imagined and what's real. Those dreams can be as gratifying as they are paralyzing, Mr. Dayton noted. "Every relationship is based on a certain amount of fiction," he said. You're drawn to someone because of that idealized vision they have of you. While Calvin scrambles to navigate Ruby's presence off the page, Ms. Kazan's script skewers her audience's expectations of the character. In recent years the archetypal on-screen male fantasy has evolved, or at least expanded. A sopping Phoebe Cates sauntering poolside in a red bikini in "Fast Times at Ridgemont High" (1982) now exists alongside Zooey Deschanel in a vintage sundress, racing through Ikea and making a goofy face in " (500) Days of Summer" (2009). The second girl - a film trope that the critic Nathan Rabin has called the Manic Pixie Dream Girl, an ethereal presence with no flaws, only endearing quirks - is the one who swoops in to save the boy from himself. Eventually Ruby's realness is Calvin's undoing. "I think I was writing in reaction to a lot of fictional female characters that have been on screen the last few years," Ms. Kazan said, "just feeling like there's a diminutive ideal of a girl that's just one shade away from being true." Mr. Dayton and Ms. Faris acknowledged the weight of those presumptions. Initially Ruby, with her purple tights and affinity for cooking and no apparent knowledge of F. Scott Fitzgerald, is a function of a certain kind of desire. "The way we dealt with it was head on," Ms. Faris said. The film is really talking about a male fantasy in a very blatant way. Ultimately the movie's ending is ambiguous, but for Calvin and Ruby the transition from fantasy to love - the sometimes arduous, often boring, those-pants-again kind - is essential. For Ms. Kazan that shift is the key to a sustainable relationship - and a strong indicator of character. Eventually, she said, love "becomes all about choice - choosing to love someone, choosing not to cheat on them. It becomes this long series of choices, and that's actually where your mettle as a person is tested.