3 Replies Latest reply on Jan 11, 2008 9:38 AM by clbeech

    How do you get an object to Follow another

    visualmc
      Ok, this project just keeps throughing me curve balls.

      I need to know if it is possible to drag one movie clip while having another movie clip following it around.

      Example I have a movie clip of a pen that is dragable and it has two hit points on the stage. The hit points are close together and thanks to the invisible box surronding the pen it hovers over both hit points. Now I would like to creat an invisible movie clip at the tip of the pen that actually activates the hit points but it also has to follow the pen when dragged.
        • 1. Re: How do you get an object to Follow another
          clbeech Level 3
          you simply need to create an event that during the drag continually repositions the 'tip' in relation to the 'pen'. In your onPress handler being the event and stop it in the onRelease, something like:

          • 2. Re: How do you get an object to Follow another
            visualmc Level 1
            that is kind of what i was thinking but this is the part i left out and it gets a little tricky. this is for a volt meter and at the other end of the "pen" i have a cord being drawn and updating as the pen is dragged. The problem lies with the orientation point having to be at the bottom of the pen and the tip.
            • 3. Re: How do you get an object to Follow another
              clbeech Level 3
              hey no problem, all you need to do is decide where you want the 'tip' to be in relation to the 'pen' and adjust the coordinates. lets say your pen slants from the bottom of the bounding box left to right like this slash ( / ) so i this case the _x position will remain at 0 and the _y position will be the _height of the box so you would adjust the coordinate in the lines above for the _y position like so:

              tip._y = pen._x+pen._height;

              or any other number depending on where you want the tip to orient to. same is true of the _x position, add a number to it if the point you want is greater or even less than the _x position of the pen :)