Fireflies were simply "flies" a longtime ago before they were called fireflies. But they did not fly around dirt or garbage dumps like ordinary flies do. They liked flying around star apple trees. The tree and its fruit so mesmerized them that they frequented star apples when the day started to fade out. And they especially became a gleeful congregation around the tree when the night became very dark. At such time, they only had the moonlight to guide them and see everything around them.
Then one night, as they were flying around the star apple tree, they noticed the twinkling stars above. That time a tribe have been languished and famished by a long hunting travel and had ended up in the middle of the forest with nothing to eat. It had been so dark, but suddenly the nocturnal clouds were parted and revealed the silvery full moon and the stars.
With aid from the faint light lent by the moon and stars, they were able to make out a tree nearby. They climbed it and ate its edible and soft, apple-like fruit. It was so sweet and fibrous, re-energizing them for the long trek the next day. The tribe had called the tree and its fruits star apple, imagining that it was a gift from the stars. So, the flies thought that, since they were the guardians of the tree and its fruits, why weren't they called starflies? So together they wished upon the stars to let them become starflies. But since stars were really burning balls, the stars gave them fire in their bodies instead.
Since then, they became and were called fireflies.