I have done similar effects by using the displacement map filter on the flag. As your displacemnet map select a layer of Fractal noise that you have precomposed, the offset of the fractal noise should be animated in the direction that you want your wind to go,use the luminance of this layer to distort the flag. With displacement, areas of 50% grey have a zero distortion, so for those parts of the flag that you want to be fixed use a grey solid with a feathered mask over the noise in your fractal noise comp (feathered to smooth the transition from static to moving parts of the flag). To give the flag some shadows, use the fractal noise comp over the flag with a composite mode like multiply or overlay, and then use a duplicate of the flag layer as an alpha matte, so that the shadows don’t exceed the boundaries of the flag. and I think that should work. Obviously there is a lot of tweaking in the Fractal noise to give you a flowing wind your happy with. Great. i’m not terribly good at explaining this sort of thing. Hope this works out, I am sure I have seen same technique in a tutorial on this site, tattered flag tut perhaps.
good luck
Peter