All-optical switching based on controlled energy transfer between nanoparticles in film arrays