Three years ago, their states were economic powerhouses and Govs. Michael Dukakis, Mario Cuomo, Thomas Kean and William O'Neill seemed politically charmed.

Now Massachusetts, New York, New Jersey and Connecticut are among nine states struggling to cope with budget deficits totaling $5.6 billion, and their governors can be excused if they sometimes feel hexed.While some fiscally conservative states in the Rust and Farm belts have piled up big surpluses, these four prosperous Northeastern states have emptied their pockets. So have Rhode Island, West Virginia, Louisiana, Missouri and Arizona.

The reasons vary, but all boil down to the same thing: The states counted on billions of dollars of income that wasn't there. And in some cases, they were victims of their own prosperity.

"When you get in those flush times and the revenue is flowing in, there's a tendency for governors and legislators and regular citizens to assume this will last forever," said Jim Verdier, who lectures on state budget policy at Harvard University's Kennedy School of Government.

It didn't last in Louisiana, where the oil boom went bust, or in New York, where the stock market crashed, or in Massachusetts, where the "Massachusetts Miracle" turned into a mirage.

In West Virginia, bad times in the coalfields got worse, and the state treasurer was impeached for losing $279 million in bad investments.

In the Northeast especially, the seeds of the fiscal crisis were planted in the federal Tax Reform Act of 1986.

Among many other things, that act raised the tax on capital gains - profits earned from stock, real estate or other property.

In most states, budget officials correctly assumed that many people would immediately sell off assets that were subject to the capital gains tax. Tax revenues would jump, but they would drop the next year when fewer people declared capital gains.

Other states guessed that there would be a much more gradual sell-off. When tax revenues suddenly climbed in 1987, those states didn't see the canyon that loomed ahead. Sure enough, revenues plummeted the next year.

"It was like getting an extra paycheck one week and then not getting one the next week," said Dall Forsythe, New York state's budget director.

The tax change particularly hurt wealthy Northeast states, which, with their many rich investors, depend more heavily than other states on the capital gains tax.

New York, New Jersey and Connecticut, home to a lopsided share of Fortune 500 companies and financial services workers, also were especially hurt by the 1987 stock market crash.

When planning began for fiscal 1989-90, governors and legislators faced deficits of $2.6 billion in New York, $700 million in Connecticut and $500 million in New Jersey. Massachusetts was about $250 million short; Rhode Island a modest $5 million.

Louisiana, determined not to raise taxes, faced a $700 million-plus deficit. West Virginia, one of the nation's poorest states, was looking at a shortfall of about $400 million.

A U.S. Supreme Court ruling in March left Missouri with a sudden $192 million deficit. The ruling said that states cannot tax federal retirees while exempting state pensioners.