Just so I'm on the same page, the guy who flirts with you is the one who flirts when your friend isn't around. And when your friend is around, he doesn't flirt?
If that's the case, then he's obviously not comfortable around being around your friend. Or maybe he's just shy flirting with other people around? I know when I'm with a girl I like, I tend to not be playful or flirty with her if she's around her guy friend (or any of her friends for that matter).
Talk to him. Communication is vital for something to work and unfurl between you two.
My best friend for the past year is a girl, and yeah we are about as close as it gets. I can say that her boyfriend absolutely hates it and she says that he won't even let her talk about me anymore. I can say that we're just friends and I have no intent of anything sexual ever happening, and she feels the same. I guess it's the feeling of being close to someone else emotionally that kind of ruins it for the boyfriend.
It's a kind of selfishness that we have with our partners, wanting them to be no one else's but ours. I guess some could consider it to be cheating but on an emotional level rather than physical.