In the month before the Trex Co. revealed that slumping sales and rising raw materials costs are eroding profits, three top officials of the Virginia maker of composite deck boards cashed in a combined $2.75 million of their stock.

Trex stock plunged more than $10 a share the day after the earnings shortfall was announced June 22, costing stockholders roughly $150 million in the value of their shares.

By selling their shares before the problem was revealed, Trex chief executive Robert G. Matheny and directors Anthony J. Cavanna and Andrew U. Ferrari together got almost $1 million more for their stock than they would have if they had waited to sell after the announcement.

Insider trading records compiled by Thomson Financial show that in the first three weeks of June, Cavanna sold Trex stock worth $1.4 million, Matheny sold $968,000 and Ferrari sold $381,000.

Ordinarily, big insider sales just before bad news is announced would trigger outcries from shareholders and probably an investigation by the Securities and Exchange Commission.

That hasn't happened because the Trex officials acted under an SEC rule that allows corporate officers, directors and other insiders to sell stock at any time, under almost any circumstances, without running afoul of insider trading regulations -- so long as the sales are "pre-arranged."

Like many federal regulations, this one is known by a paragraph number from a rulebook: 10b5-1.

Drafted five years ago to clarify insider trading laws, the rule allows senior corporate executives and directors who are considered corporate insiders to set up the pre-arranged stock trading plans. Typically, the executive or board member notifies the SEC of the intent to sell a certain number of shares over a certain period of time, then turns over the task of actually making the trades to a stockbroker or another designated representative.

Trex, for example, served notice on May 13 that under "the rule 10b5-1 sales plan, Mr. Matheny may sell up to 260,000 shares of Common Stock through Nov. 16, 2005." That would have amounted to about $10 million worth of stock based on what Trex shares were selling for at the time, but considerably less than that since Trex stock dropped. Matheny's sales in June were made under that notice.

Matheny terminated the stock sales plan on June 23, the day after Trex announced its expected earnings shortfall, according to a Trex filing with the SEC.

Matheny has offered no public comment on his sales under the pre-arranged plan or on his decision to cancel it. Nor did company officials respond to calls seeking comment for this article to the offices of Matheny, Chief Financial Officer Paul D. Fletcher or the New York public relations firm that represents Trex.

Securities lawyers say pre-arranged sales plans are being used more often. Once such a sales plan is made and filed with the SEC, insiders can sell stock with impunity -- even if they learn some "inside information" that would otherwise disqualify them from selling, said lawyer Gregory S. Bruch, a former SEC staff member who is now a partner in the law firm of Foley & Lardner.

"It's actually contemplated that things like this may, or may not, occur," Bruch said. The rule was written to clarify confusing regulations and court decisions that made it difficult to determine when insiders could properly sell stock. In giving insiders this "safe harbor" for pre-planned selling, the regulations also gave the SEC greater authority to go after improper insider trading.

The announcement of bad news on June 22 was an unaccustomed jolt for Trex, which has been one of the region's most successful new companies since it went public in 1999.

Company officials have said that they realized things were going off track only two weeks before the company announced the anticipated shortfall in sales and profits.

In the June 22 announcement, the company indicated that wholesalers who distribute the Trex line weren't reordering inventory as fast as expected and expansion into Home Depot stores was taking longer than it should, even as raw materials costs were rising. Bad weather in many parts of the country also had delayed the start of the deck-building season.

The bottom line: Instead of second-quarter sales in the $100 million range, Trex said it would do $75 million to $80 million worth of business. Instead of earning 90 cents a share in profit, as analysts had projected, Trex would lose 20 to 25 cents a share for the quarter. The company also lowered its earnings guidance for the year.

Analysts at BB&T Capital Markets immediately downgraded the stock from "buy" to "underweight," the equivalent of "sell" in BB&T's rating system.

Trex stock, which was trading for $35.70 before the announcement, plunged to $25.11. After bouncing around a bit, the stock has stabilized near that level, closing Friday at $25.51.

Trex has its main manufacturing plant in Winchester. The corporate headquarters is there now as well, but will be moving to a new office building at Dulles Town Center, developers of that project announced last week.

The company is the nation's largest and best-known maker of non-wood deck boards, a category that includes various plastic and plastic-and-wood products made by a dozen manufacturers. Trex decks are made of wood scraps -- leftovers from furniture making and lumber mills -- and recycled plastic, mostly grocery bags. The company says it is the nation's largest recycler of grocery bags.

The plastic and wood are heated and mixed in giant blenders and then extruded into boards much like spaghetti coming out of a pasta machine. By adding colors and embossing the surface of the boards, Trex makes decking in more than a dozen tones and styles. Matching materials for railings are part of the line.

The process was developed by the chemical division of what is now Exxon Mobil Corp. But after Trex got off the ground, the parent company decided decking didn't fit into the oil business, so it sold the operation to the executives who had been running it.

Matheny, Cavanna, Ferrari and Trex inventor Roger A. Wittenberg each put up $500,000 of his own money and arranged financing for what proved to be an enormously successful management buyout.

Each of the founders took out $2 million in cash before the company went public and has sold millions of dollars worth of stock since then. Wittenberg left Trex and went on to pursue another invention. Cavanna and Ferrari have retired as executives of Trex but remain board members.

Cavanna, Ferrari and Matheny are the company's largest individual shareholders. At the time of the Trex company annual meeting in April, Cavanna owned about 1.4 million shares, Matheny about 1.2 million shares and Ferrari about 700,000.

Since then, all three have sold significant amounts of their stock, much of it under the 10b5-1 pre-arranged sales rule.

The Thomson financial insider trading reports show the executives selling shares almost every week this year, dribbling them out slowly, which minimized any effect on the stock price. The last sale -- 5,000 shares sold by Ferrari -- was completed on June 22, the day the shortfall was announced.

Their total sales from January through June 22 came to $19.3 million -- $7.6 million by Cavanna, $6.2 million by Ferrari and $5.5 million by Matheny, according to Thomson.

Still, profits have been impressive for Trex shareholders too, at least until now. Even including the stock's recent decline, $100 invested in Trex stock when it went public would be worth $250 today.

Trex founders Anthony J. Cavanna, left, Roger A. Wittenberg, Robert G. Matheny and Andrew U. Ferrari each put up $500,000 of his own money and arranged financing to buy the Trex operation from parent company Exxon.