3 Replies Latest reply on Jun 12, 2007 4:18 PM by kglad

    Finding closest target

    Gooms9
      Hello there, i've got a ball movie clip named ball, and 4 targets in each corner of the screen. What I want to do is dynamically find the closest target and then get the ball to move towards that target. I've come close to getting it working, but for occasionally when I run it, the ball will travel towards a target that is definitely not closest to it. I've got a sneaking suspicion that it has to do with my distance formula, but I figured i'd post here and maybe someone might be able to shine a light on what's wrong or point out an easier/more efficient way of performing this task. Heres my code. The only thing that isn't in the code is my ball movie clip which is just a red circle in the library with the linkage identifier "ball". Everything else is simply code. I know this is quite a bit of code to sift through, but i'd appreciate any help/tips/suggestions. Thanks.