Drag racer game

hi all

i wanna develop game something like http://www.flashgames247.com/play/241.html this.i still wont able to find the way how to make the race b/w opponent and hero? and how can i detect when the race is completed??looking forward to ur help.