It's an image out of your mooniest daydreams. High over the ocean, drifting through a perfectly dappled blue sky, a colossal orange peach, smooth and succulent and as big as a small house, floats serenely on its way to nowhere, its bulk held aloft by a flock of seagulls, its ''crew'' a young boy and his oversize insect friends. At its lyrical best, James and the Giant Peach, an adaptation of Roald Dahl's 1961 children's classic, evokes the casual enchantment of a book that, for many kids (including me), cast the spell of a goofily blissed-out mirage. Coproduced by Tim Burton and Denise Di Novi and directed by Henry Selick, the picture employs the same astonishingly detailed stop-motion animation technique used in the team's previous collaboration, Tim Burton's The Nightmare Before Christmas (1993). But that movie was murky and scattershot, with a hero who looked like a scarred golf ball. James and the Giant Peach is simpler, more delicately beautiful, and a lot more fun.
Dahl's book merged the grave formality of a Victorian fairy tale with something more deliciously far-fetched a gentle psychedelic lyricism. In England, James Henry Trotter, an orphan, lives in misery with his two spinster aunts, Spiker and Sponge, who are like Cinderella's stepsisters all grown up. But then a way out of prison appears: In the garden, James meets a mysterious old man who hands him a bag of glowing green critters. Tossed into the earth, they inflate a hanging peach and a handful of local insects to monster size, and James is soon off on his odyssey of escape.
Like Alice's Adventures in Wonderland and the Wizard of Oz books, James and the Giant Peach is the rare children's fable that throws off glimmers of adult knowingness (those green things might be as sly a drug reference as ''Lucy in the Sky With Diamonds''). All of which makes it perfect for a warped prankster like Burton. The sculpted animated figures really come alive this time, with the pushy, querulous insects, including a Brooklynese Centipede (voiced by Richard Dreyfuss), a cultivated British Grasshopper (Simon Callow), and a throaty, Garboesque Miss Spider (Susan Sarandon), emerging as funny, foibled characters. When they launch into a giant-bug production number celebrating the peach's gustatory glories (the songs are by Randy Newman, with some lyrics by Dahl), all the while scooping out peachy mouthfuls so juicy and glistening you can practically taste them, James and the Giant Peach achieves a joyously unhinged, go-with-the-flow loopiness the domesticated surrealism that gave Dahl's book its pungency.
Unfortunately, the animation is framed by stridently crude live-action scenes that effectively douse the spell. In the opening section, James' crooked house is transparently a movie set, and the actresses playing the aunts, Joanna Lumley and Miriam Margolyes, overdo the shrieky, hothouse camp, as if they were wicked witches gone absolutely fabulous. The leap to animation, when it comes, is jarring, but also a relief. James and the Giant Peach doesn't really take off until the witty moment in which James and his insect pals use the blind, doleful Earthworm (David Thewlis) as seagull bait. The film then becomes a succession of eye-popping terrors and wonders, from the jagged mechanical shark that tries to shoot down the peach to the stirring moment when James strolls around the peach's twisty footbridge in the middle of the night, a lost boy in search of home. There are marvelous visual touches throughout; it took most of the movie before I noticed that Miss Spider was wearing high-heeled hip boots.
Finally, the peach arrives in New York City and James and the Giant Peach, I'm afraid, comes crashing down with it. The transition back to live action is an egregious, mood-squashing mistake: The last thing we want is to abandon the fantasy for this clunky, backlot Manhattan, and for the return of characters we'd hoped were long gone. Oh, well. Burton and company are working in the right spirit in James and the Giant Peach, their animation artistry has wit and soul. If only they'd trusted it more, they might have made a marvelous kids' film instead of a merely charming one.