Why does the shower get cold when I flush, and how can I prevent it?
Why you get burned
One of the most common plumbing configurations, is a trunk and branch system.  This is where a larger diameter pipe runs from one end of the building to the other, and smaller diameter pipes branch off to supply rooms or individual fixtures. If any of the branches demands water (you flush the toilet), there is less water available to all the other branches.
Since the toilet only uses cold water, there is less cold water available to your shower when the toilet is filling.  This causes the water in the shower to be warmer, because there is less cold water mixing with the hot water.
How to stay comfortable
There are a few ways to reduce, or eliminate this burning feeling. Probably the cheapest, is to reduce the amount of water going to the toilet.
Reducing toilet water
You can reduce how quickly the toilet uses water, by simply closing the supply valve slightly.  This means the toilet will take longer to fill, but will reduce the temperature fluctuation in the shower.  Adjusting the supply valve can also have negative side affects, such as increased fill times, and noise.
You can also reduce the overall amount of water the toilet needs.  You can accomplish this by either buying a low flow toilet, or placing a brick, jug of water, or other object in the tank.  However, this method will reduce the amount of water available for each flush, so you may encounter difficulty clearing solids from the bowl.
Smarter mixing
Installing a new mixing valve in the shower, can reduce or eliminate the temperature fluctuations. Thermostatic mixing valves automatically balance the amount of hot and cold water being mixed, which will prevent drastic fluctuations in shower temperature. If the cold water flow is reduced (due to a toilet flush), the valve automatically adjusts the amount of hot water being mixed. This keeps the shower temperature more consistent, even when other fixtures are using water.
Increasing available water
Increasing the amount of water available in the system can alleviate the problem, but will likely require a major change to the plumbing.
If you have a trunk and branch system, increasing the trunk pipe diameter and/or the branch pipe diameter (if the branch feeds the entire room) will increase the amount of water available to the fixtures.
Distributing water evenly
A more drastic solution, would be to install a manifold with home runs.  This would likely require a major plumbing renovation, with almost all of the plumbing changed.
In this type of system, there is a central load balancing manifold.  Then for each fixture in the house, a dedicated pipe is run between the fixture and the manifold.
Supply and Demand
In the end, it's all about supply and demand.  If the demand is greater than the supply, you end up with a burnt butt. The only way to avoid uncomfortable showers is to reduce demand or increase supply.