SAN FRANCISCO -- Zynga, the one-time Silicon Valley darling that has been wrestling with a months-long exodus of online gamers, reported an unexpected fourth-quarter profit on Tuesday,

Revenue was virtually flat from a year ago, but was down from the prior quarter. And Zynga's underlying business appeared to be continuing its downward slide, as the maker of "CityVille 2" and other games projected revenue could shrink for a third sequential quarter.

The San Francisco game maker reported a quarterly profit of 1 cent per share on an adjusted basis, beating expectations for a loss of 3 cents per share, according to analysts polled by Thomson Reuters.

Shares of Zynga rose 5.8 percent to $2.90 in after-hours trade on the results.

Fourth-quarter revenues were $311 million, virtually unchanged from a year ago. Zynga forecast revenue for the first quarter of 2013 of between $255 million and $265 million, a roughly 20 percent drop from the same quarter in 2012.

Once hailed as one of Silicon Valley's fastest growing companies, Zynga suffered a dramatic reversal in 2012, when users began to abandon its once-popular games like "CityVille." The company was also caught off-guard by a sea change in consumer behavior, as people spent more time on their mobile phones instead of desktop computers -- the platform for most of Zynga's most lucrative, Facebook-based games.

During the quarter, Zynga's daily active users fell to 56 million, down from a high of 72 million in the second quarter of 2012.

In October, Zynga CEO Mark Pincus laid off staff and announced $200 million in stock buybacks after the company forecast a loss for the December quarter.

He has also vowed to make smartphone-based games a centerpiece of Zynga's line-up.