Flexible thin-film device