Ok. The reason that you're stretching your legs is inside the muscles. A muscle can be compared many rubber band that's using a pole to keep up. When you're stretching your legs, one or more of these rubber bands brakes because they're being used to much. If you make sure to warm up really, the rubber bands will be prepared and ready to being used. That's because you dilate them before to make them ready.
You should walk on it, but not push it to its limits. Resting is good, but don't let it stiffen (right word?) completely. How long you should wait depends on how bad the damage is but if you get hurt by moves like Tatw, Amatw etc. (Tricks that require a movement in your stretched leg) you should let it rest more.
By the way: When i say rest i mean that you should walk on it but don't run, jog etc. cause that will make the damage worse.
If you have problems with stretched muscles because of freestyle you should make sure to warm up really, so the muscles will be warm. If you live in a cold place it's extra important, and then you should have some stilongs (right word again?) under your shorts. You can also get a salvo you can lubricate on your leg to make the muscles warmer. Also remember to stretch out often and good, so the risk of stretch or cramp will reduce.