Usually their flirting and 'nice' behavior is to keep you as plan B while she waits for her Mr. plan A to come along. Don't even give her the slightest hope that she could always come back to you.
How do you detach? I don't know if I have a concrete answer but most people say you fake it till you make it. Build some structure around your life so you have things to do throughout the day...almost like a routine. After a while you'll get comfortable in it. Do some fun things for yourself. Join meetup.com and go play tennis, golf or whatever you're into. It takes time but at least you seem to be ahead of the game than most of us when we were there.
Me: 35|WAW: 38|D: 6yo | http://tinyurl.com/2dxx7m6 Feb 2006, left, came back in two weeks Aug 2006, left again Apr 2007, filed for divorce Dec 2007, reunited Mar 2010, moved out, filed again