
469 So.2d 915 (1985)
CITY OF CLEARWATER, Appellant,
v.
UNITED STATES STEEL CORPORATION and U.S.S. Realty Development, Appellees.
No. 84-1628.
District Court of Appeal of Florida, Second District.
May 24, 1985.
Charles L. Siemon and Susan G. Connelly of Siemon, Larsen & Purdy, Chicago, Ill., and Frank Kowalski, Chief Asst. City Atty., Clearwater, for appellant.
Dennis P. Thompson of Richards, Nodine, Gilkey, Fite, Meyer & Thompson, P.A., Clearwater; Thomas F. Icard, Jr. and James O. Davis, III, of Carlton, Fields, Ward, Emmanuel, Smith & Cutler, P.A., Tampa, for appellee U.S. Steel Corp.
PER CURIAM.
The appellant, City of Clearwater, appeals from an order dismissing its complaint *916 seeking a declaratory judgment. We affirm.
In 1979, the Circuit Court in and for Pinellas County, Florida, entered a summary judgment determining that the City of Clearwater was bound by a contract of annexation between it and the predecessor-in-interest of the appellee, United States Steel. The summary judgment enjoined the city from enforcing an ordinance that would rezone property belonging to United States Steel. This court affirmed that summary judgment on March 5, 1980, 381 So.2d 774.
On January 24, 1984, the city filed a motion for relief from summary judgment pursuant to Florida Rule of Civil Procedure 1.540(b). The city alleged in its motion that the summary judgment was void, that prospective application of the judgment was no longer equitable, and that equity commanded relief from the judgment. The trial court denied the city's motion and this court affirmed in City of Clearwater v. United States Steel Corp., 462 So.2d 1171 (Fla. 2d DCA 1985).
The city had also filed on January 24, 1984, a separate action seeking a declaratory judgment by the court that conditions had changed since the entry of the original summary judgment and that the city therefore had the power to rezone the property. United States Steel filed a motion to dismiss the city's complaint in this action on the grounds of res judicata. At the hearing on the motion to dismiss the complaint, the parties agreed that the court could take judicial notice of the record in all other proceedings between the parties. United States Steel's motion to dismiss was granted, and this appeal timely followed.
The city contends that United States Steel did not properly raise the defense of res judicata in its motion to dismiss. We disagree. The city is correct in arguing that the issue of res judicata is an affirmative defense, and affirmative defenses cannot be raised in a motion to dismiss unless the allegations of a prior pleading in the case demonstrate their existence. Ecological Science Corp. v. Boca Ciega Sanitary District, 317 So.2d 857 (Fla. 2d DCA 1975); Temples v. Florida Industrial Construction Co., Inc., 310 So.2d 326 (Fla. 2d DCA 1975). In considering a motion to dismiss, the court must confine itself solely to the allegations within the four corners of the complaint. Ecological Science. Since the denial of the city's relief from summary judgment in the earlier action was not mentioned in the complaint which is the subject of our review, we would normally hold that the defense of res judicata could not be raised by United States Steel in its motion to dismiss. The parties, however, stipulated that the court could consider and take judicial notice of all other proceedings between them. The trial court therefore properly considered the issue of res judicata. See Mennella Plastering, Inc. v. Adobe Brick and Supply Co., Inc., 273 So.2d 1 (Fla. 1973); Lagarde v. Outdoor Resorts of America, Inc., 428 So.2d 669 (Fla. 2d DCA 1982); cf. Kostecos v. Johnson, 85 So.2d 594 (Fla. 1956).
A review of the pleadings and evidence presented in the prior case, and a review of the complaint currently before us, indicates that the substance of the factual allegations in both actions, the theories upon which relief was sought, the type of relief sought, and the parties are identical. The trial court therefore properly dismissed the case on the basis of res judicata. See Hay v. Salisbury, 92 Fla. 446, 109 So. 617 (1926); Lagarde; Huskey Industries, Inc. v. Griffith, 422 So.2d 996 (Fla. 5th DCA 1982). Although we find the trial court acted properly, we note that we have not been called upon to determine the propriety of United States Steel's argument had the case been presented in a different posture, e.g., if United States Steel had applied for a building permit and it had been denied, or if the city had attempted to rezone the property and United States Steel had contested the rezoning.
AFFIRMED.
OTT, A.C.J., and CAMPBELL and SCHOONOVER, JJ., concur.
