Well, this has worked for me anyway.
My friend flirted with my boyfriend when he was someone I fancied, but he was kind of off limits, but soon after we had started going out and she had continued doing this, I had a word with her about it, and she stopped almost immediately and was sorry.
It really does help to talk.