Optical switch utilising attenuation