James D. Smith, 86, a retired analyst with the National Security Agency who later in life became a bit-part actor in three major films, died after a heart attack Nov. 7 on his way to Greater Baltimore Medical Center. He lived in Baltimore.

Mr. Smith worked for 26 years for the NSA and one of its predecessor organizations, the Armed Forces Security Agency. Although his family was kept in the dark about his career, Mr. Smith's son said that his specialty was cryptology and that he served as a policy staff officer. Mr. Smith won the Meritorious Civilian Service Award, the Defense Department's second-highest civilian award, for his work.

After his retirement in 1977, Mr. Smith accompanied his second wife, a civilian personnel manager with the NSA, to a three-year posting in Yorkshire, England. While there, he auditioned and won walk-on spots in three films: "Agatha" (1979), "Yanks" (1979) and "Reds" (1981). He can be seen in the background of a number of scenes, dancing or as part of a crowd.

Mr. Smith was born in Omaha. A highlight of his childhood was at age 6, when he won a pony in a department store drawing. He grew up during the Depression, graduated from the University of Nebraska in Omaha in 1941 and received a master's degree in history from what is now Case Western University in Cleveland.

He joined the Navy during World War II and moved to Washington to work in communications and intelligence at the Naval Intelligence facility on Nebraska Avenue NW. He lived with other officers in a boarding house in Mount Pleasant and met his future wife while riding the bus home from work.

Mr. Smith began to teach after the war, working at the University of Maine and the University of North Carolina. Summoned by former commanding officers, he joined the Armed Forces Security Agency in 1951. It became the NSA in 1952.

He attended George Washington University's law school at night, receiving a law degree in 1956. He served for a time as president of the Hillandale Citizens Association in Silver Spring, a role in which he unsuccessfully fought the erection of the giant Coca-Cola sign above the bottling plant at New Hampshire Avenue and the Capital Beltway.

Mr. Smith enjoyed camping, gardening, bicycling tours of Europe, cooking classes in England, and reading the New Yorker magazine and The Washington Post, which he helped his son deliver on rainy and snowy mornings. He also manned the Hillandale Elementary School Fair hot dog stand each spring. He moved from Silver Spring to Baltimore County in 1987.

His first wife, Marjorie Blaisdell Smith, died in 1969.

Survivors include his wife of 32 years, Olive Milne Smith, of Baltimore; three children from the first marriage, Thomas B. Smith of Washington, Janet Smith Thompson of Sykesville and Julia Smith Michaud of Hampden, Maine; and six grandchildren.

James D. Smith appeared in "Agatha," "Yanks" and "Reds."