Constraining/Avoiding Organic Shapes

Hello all,

I’m currently working on a 2D (top view) racing game and I’m currently stuck trying to figure out how to keep the motorbike inside the racing track.

I’ve read about hittest but I failed when I tried coding it into the game as I’m not too familiar with it so I’ve resorted to a constrain/avoid script. I’ve tried but it won’t work because the shape of my track is pretty organic. Is there a way for me to constrain the motorbike to an organic shape???

Also, the script that I found, is applied to a mouse movement and not a movieclip like i want it to and I’m trying to figure out how to apply it to a movieclip. A file of the script I found is attached.

EDIT
For those who’ve viewed this, I found a solution at actionscript.org