This might be well off - but try absoluting your distance check, like:
dis# = abs(sqrt(((ox#-x#)^2) + ((oy#-y#)^2)))
This would set it so dis# is always positive, I think if you don't do that sometimes the distance check is negative. Worth a try at least.
One thing though - are you calling this every loop?
It strikes me that you could optimise that a little, like only checking objects that are in the screen, and only hiding/showing when absolutely necessary. For example, if you had an array that just stored the visibility state of each object, you could do something like (assuming visible(obj) is the array name):
if dis# > 1000 and object in screen(c)=1
if visible(c)=1 then hide object c : visible(c)=0
else
if visible(c)=0 then show object c : visible(c)=1
endif
Hiding and showing objects is fairly slow, so don't replicate the hiding or showing that you've already done in the previous loop. It's actually faster to check if an object is visible before hiding it than just hiding it regardless.
Van-B