We use the cannonball (CB) model of gamma ray bursts (GRBs) and their afterglows (AGs) to analyze the observational data on X-ray flashes (XRFs) and their AGs. We show that the observations support the CB-model interpretation that XRFs, like GRBs, are produced by the explosions of core-collapse supernovae (SNe) akin to SN1998bw, by jets of highly-relativistic CBs. The XRFs and GRBs are intrinsically identical objects, but the XRFs are viewed from angles (relative to the jet direction) which are typically a few times larger than the typical viewing angles of "classical", long-duration GRBs. There should be XRFs, not observed so far, with durations similar to those of short GRBs.