Well first you need the Friend Area called Dragon Cave.
It unlocks a certain dungeon called Wyvern Hill.
Fly is in the chamber on the 30th floor.. you need a key for it obviously.
You can find keys for chambers scattered on the ground in Solar Cave. :3
The only legit way to obtain the Time Flute in XD is by obtaining it in a trade.
For instance putting the Time Flute on a Colosseum Pokemon and trading that Pokemon to a GBA Pokemon game.
Then trading that Pokemon from the GBA to XD.