Waving flag in After Effects from vector
The simplest way would be: 


Create your flag in Illustrator
Think about or simply test how many frames/steps are key for animation
Draw your frames/steps on seperate Illustrator layers in to get the same position for all of it
Paste your frame/path with CTRL+V on 1 solid layer every 4-20 frames by switching between After Effects and Illustrator back and forth - time depends on your animation


Explanation: Through pasting the masks at a different time, After Effects automatically creates keyframes of the mask shape property. All copied shapes become interpolated keyframes like a roto shape animation to get soft transitions. 

Note: The only limitation is that the number of anchor points per vector image should remains the same to get soft interpolation between the shape keys.