The symptoms you are describing sound consistent with a phenomenon called photopsias. These are usually solitary and random flashing lights that can happen at any time, but usually happen when the eye is rubbed, or when the pupils changes diameter (such as changing lighting environments), or when the eye moves.
The photopsia is a direct result of traction on the retina. There is jelly occupying a large volume of the back of the eye which is attached to the retina which is at the very back of the eye. As we get older this jelly starts to liquefy and there are tractional bands which pull on the retina as these things happen. When they do, your brain interprets this as a flash.
Often times little floating things (like dots or spider webs or gnats) tend to float around the vision and are more often seen against a bright or white background. Regardless of whether your have floaters or not, you should be aware of the signs of a retinal detachment, since this is the worst possible sequelae of these photopsias. 1) a sudden onset of numerous floaters, 2) these photopsias, or flashing lights, that are not just intermittent and solitary but that are persistent and consistent, not going away; 3) a shade or shadow pulling over your vision that you can't see through; and 4) your vision getting a lot worse all of a sudden. For any of these reasons you should seek help from an ophthalmologist immediately. This complication is fortunately rare, but it's good to at least know those signs in advance.
Does this help answer your questions?
I am happy to be able to help you today. If you would be so kind, please help me get credit for my efforts in answering your questions and press the ACCEPT button for this encounter. I would also be happy to continue to answer any more questions you have until we have resolved your concern.
Also, any positive feedback and/or bonus you may feel prompted to provide would be welcomed and is appreciated.
My opinion is solely informative and does not constitute a formal medical opinion or recommendation. For a formal medical opinion and/or recommendation you must be examined by your doctor.