Enemy distance

How can I check to see if the distance between the 2 objects Bandit and Character is less than 20 and if it is then activate the function banditAgressive ();.

So far I’ve tried subtracting the _root.names._x etc from each other and used the

if(playerDistX <20 or playerDistY <20){
banditAgressive ();

Doesnt work. I havent used distances before so can anyone guide me on a decent way to do this?