Ray Sharkey, the hard-living actor who starred in television’s “Wiseguy” and the movie “The Idolmaker,” died of AIDS complications, his manager said Saturday. He was 40.

Sharkey died Friday about 5 p.m. at Lutheran Hospital in Brooklyn, said Herb Nanas from Los Angeles.

“AIDS was a denial variable with him for so long. But he knew he had to make peace with himself, and AIDS just caught up with him,” Nanas said. “He certainly was sorry he fooled around with heroin.”

Sharkey battled cocaine, heroin and alcohol throughout his career and was a self-declared juvenile delinquent who spent his youth in Brooklyn gangs. “I always knew I would fall big time,” he said several years ago.

He was treated for chemical dependency in 1987. But in July 1992, he was arrested in Canada for narcotics possession. The heroin arrest cost him a part in the television series “The Hat Squad.”

In a lawsuit, actress Elena Monica accused Sharkey of infecting her with the AIDS virus. Nanas said that Sharkey contracted AIDS through intravenous drug use.

He had several drug overdoses and four drug-related car accidents.

The son of a professional drummer who abandoned him and his mother when Sharkey was 5, Sharkey fell for acting when he saw Jack Lemmon’s portrayal of an alcoholic in 1962’s “Days of Wine and Roses.”

His feature film credits included “Trackdown,””Stunts,””Paradise Alley, “”Who’ll Stop the Rain,””Heartbeat,””Willie and Phil,””Love and Money,””Some Kind of Hero,””Scenes From the Class Struggle in Beverly Hills””Wired” and last year’s “Zebrahead.” His final appearance was that of a gangster in this year’s “Cop and a Half.”

In 1980’s “The Idolmaker,” Sharkey played a rock promoter based on the real-life producer Bob Marcucci. He won a Golden Globe award for the performance. Sharkey also played John Belushi’s guardian angel in “Wired.”

On television, he appeared in “Capone in Prison,””Neon Empire,””27 Wagons Full of Cotton” and the series “Barney Miller,””The Jeffersons,””All in the Family,””Starsky and Hutch” and “Crime Story.” In 1991, he starred as a womanizing con man in the comedy “Man in the Family.”

On “Wiseguy,” he played mob boss Sonny Steelgrave.

Survived by his mother, his daughter and two ex-wives, Nanas said.