Afanasenkov had spent his entire career in Tampa after being drafted by the Lightning in 1998. He was also part of the team's Stanley Cup win in 2004.
The 26-year-old Russian has appeared in 33 games this season, scoring three goals and six points while registering a minus-6 rating.
"Dmitry is a well-rounded player," said Flyers GM Paul Holmgren. "He's very smart defensively and has good skills."
Philadelphia is currently the league's worst team. The Flyers have just nine wins and 22 points heading into play on Saturday.