Why is my ex-fling so rude towards me?

Me and this guy had a very small "thing" with each other like a year ago. I guess he felt rejected because I wouldn't go out on a date with him so he ended up rejecting me in a HUGE way after that, and openly came onto my friend in front of me to spite me. He's now together with my friend, and I thought we were cool but he always takes sly digs at me randomly. Another girl said I was pretty the other day (she was just being nice to be fair) and he goes to her "she's not all that, me and my girlfriend are better-looking." He takes digs at my intelligence saying I'm air headed and forgetful, when there is really no need. Why is he acting like this?
Why is my ex-fling so rude towards me?
Post Opinion