# I need a piece of Awesome code or translated to as3

**URL:** <https://forum.kirupa.com/t/i-need-a-piece-of-awesome-code-or-translated-to-as3/317057>\
**Category:** Uncategorized\
**Created:** [December 9, 2010, 7:14am UTC](https://forum.kirupa.com/t/i-need-a-piece-of-awesome-code-or-translated-to-as3/317057 "2010-12-09T07:14:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Numinus](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Numinus](https://forum.kirupa.com/u/Numinus)\
**Post date:** [December 9, 2010, 7:14am UTC](https://forum.kirupa.com/t/i-need-a-piece-of-awesome-code-or-translated-to-as3/317057/1 "2010-12-09T07:14:37Z")

</div>

This is some great code by peter joel that alows you to drag along a custom path. I need to do the exact same thing in as3. I’ve been trying to do it on my own, but with no luck. I’m halfway decent with as2, i’m an as3 dummy. Can someone help please?

```auto
 
 
onClipEvent(load){
 var drag = false;
 var error; // max number of pixels out
 var tolerence = 1; // max error
 var x; // current x approximation
 var y; // current y approximation
 var yAbove = 0; // best Approximation above line
 var yBelow = 400; // best Approximation below line
}
onClipEvent(enterFrame){
 if(drag){
  x =_parent._xmouse;
  y =_parent._ymouse;
  do{
   if (_root.belowLine.hitTest(x,y,true)){
    yBelow = y;
    y = (y+yAbove)/2;
   }else{
    yAbove = y;
    y = (y+yBelow)/2;
   }
   error = yBelow -yAbove;
  } while (error > tolerence);
  yAbove = 0;
  ybelow = 400;
  _x = x;
  _y = y;
 }
}
 

```
