From PEOPLE Magazine Click to enlarge
On the set of her Lifetime movie Flirting with 40 this spring, Heather Locklear seemed at her sunny, California-girl best. During a four-week shoot in Canada and Hawaii, the 46-year-old actress learned to ride the waves so she could do her own surfing stunts, turned heads with her bikini body and spent downtime giggling with visiting boyfriend Jack Wagner. "Heather was a joy to work with," says executive producer Judith Verno. "She was up for any challenge. She's funny, charming, and of course she looks absolutely beautiful. It was like having your best girlfriend on the set with you."

But those closest to Locklear knew that behind her famous smile, the star was in anguish. Ever since her 2006 split from rocker Richie Sambora—the pair have a daughter, Ava, 10—and his subsequent relationship with her former friend Denise Richards, Locklear had struggled with intense unhappiness, for which she sought medical help. Finally, on June 19, she voluntarily checked herself in to an Arizona treatment center to confront her emotional and psychological problems. "Heather has been dealing with anxiety and depression," her publicist Cece Yorke tells PEOPLE. "She requested an in-depth evaluation of her medication and entered into a medical facility for proper diagnosis and treatment."

Although the move may come as a shock to fans of the Dynasty and Melrose Place actress, many in her inner circle say the decision came after a series of personal setbacks that left her unable to cope. "She didn't go because she was forced," says a longtime associate. "There was no intervention. She went in on her own. She wanted to feel better and get to the bottom of what was troubling her."

In recent months, friends say, Locklear's behavior seemed erratic. Sometimes she was uncharacteristically somber. "She's usually very playful and sweet," says someone who knows her socially, "but she had been changing." On other occasions "she wouldn't stop talking; she just seemed out of it."

While sources say Locklear's depression led her to drink alcohol, others close to the actress maintain she is not being treated for substance abuse. "Did she like to have fun and drink on occasion? Absolutely," says a close friend. "But alcohol has never been a problem for her. She just isn't a drunk."

What is true, says the friend, is that Locklear started taking prescription drugs for anxiety and depression in 2006, after she found an e-mail to Sambora, 48, containing provocative pictures of a mutual acquaintance and later filed for divorce after 12 years of marriage. There have been bright spots since: in particular, Locklear's romance with her former Melrose costar Wagner, 48, whom she's been dating since April 2007. "He's been so great for Heather, a fantastic influence," the close friend says of the divorced father of two. She has also drawn strength from her close relationship with her daughter. But there were also days when she struggled. Says the friend: "She puts a brave face on. She's held it together, but something just felt off. It just got to the point where she wanted to feel great again."

Her friends grew increasingly worried in recent months, as Locklear's problems appeared to worsen. "Things seemed to take more effort than they should have," says her friend. "Her enthusiasm for exercise and golf wasn't there. There was just a general, underlying malaise. Then when something would happen, she'd have anxiety, and it was harder to get a handle on it. She was suffering."

For all the times she seemed to make progress, says the friend, there seemed always to be a dramatic turn that put Locklear back at square one. In March Sambora was arrested for DUI while daughter Ava was in the car (he pleaded guilty to drunken driving and was sentenced to three years' probation). That same month an acquaintance called 911 and reported he feared Locklear was suicidal; a source tells PEOPLE the actress had been "bummed" over a personal problem and the person had overreacted. Explains the close friend: "Heather said, 'I'm almost afraid to say I feel better, because every time I do, something [bad] happens.'"

Just before heading to film Flirting—about a woman who weathers a divorce and finds happiness with a younger man—Locklear consulted a new doctor, who said she had been prescribed the wrong medication and suggested she head to an inpatient facility so she could be fully evaluated and put on the appropriate drug therapy. After the shoot wrapped in May, "she was so over not feeling well," says the friend. "She just said, 'Let's go. Where do I sign up?'"

Since checking in, Locklear has been focused on getting better, living at a gated residential treatment center in Arizona—a world away from Hollywood. Back home, family, friends and even her ex are all standing by her. "Richie is concerned," says a friend of the musician's. "He's very involved in Ava's care during her mother's time away. He is in contact with everyone and is supportive of Heather." While her father tours in Europe with Bon Jovi, Ava is "with family and continuing on with her summer plans," says Locklear's friend. And Locklear can still count on Wagner. "Anyone who has the courage to seek help in order to live a healthy life gets my support 110 percent," the actor tells PEOPLE.

For now, the actress is taking her recovery step by step. "Once she's feeling better, she'll come home," says her good friend. "There's no time frame." Loved ones say her determination to heal is as much for her daughter as for herself. "Ava really loves her and spends most of her time with Heather, so being healthy for Ava was important," says the close friend. "It's great that she's finally taking care of things and moving forward."

  • Contributors:
  • With reporting by Jennifer Garcia/Los Angeles,
  • Liz McNeill/New York City.