In this letter, the eigen-analysis-based optimal design method of orthogonal block transform, the so-called Karhunen-Loeve transform, is used to generate a new family of spread spectrum codes. These spread spectrum and varying power orthogonal codes might find their application in direct sequence code division multiple access (CDMA) communications. The basis functions of the proposed transform are jointly spread in the time and frequency domains. This property is in contrast with the traditional optimal block transforms maximizing energy compaction due to their frequency localized basis magnitude functions desired in source coding and spectral processing applications. Bit-error rate (BER) performance of the proposed CDMA spreading codes under both additive white Gaussian noise (AWGN) and Rayleigh flat fading channel conditions are compared with the industry standard codes like Walsh and Gold families. It is shown in this letter that the proposed technique allows us to design orthogonal spreading codes with flexible lengths that perform comparable to or better than the Gold and Walsh codes.