— In this paper, we consider time-and-frequency hopping (TFH) codes for optical code-division multiple-access (OCDMA) networks. To support the differentiated service requirements for multimedia data transmission, we propose twodimensional TFH codes with arbitrary cross-correlation constraints. Using the proposed codes, we can increase the cardinality of the codes compared to the conventional OCDMA codes whose cross-correlation value is usually confined to at most one. To design a TFH code that can support differentiated requirements on bit error rates (BERs), we propose an efficient construction method which can generate TFH code sequences with hierarchical cross-correlation constraints. The cardinality bound of the proposed codes with mixed cross-correlation constraints is also derived. From the numerical results, we demonstrate that the proposed codes can obtain relatively differentiated BER performances by providing hierarchical constraints on the crosscorrelation values.