Reversing the animation in a movie clip

i am having a problem in reversing the animation in a movie clip i am posting the function i used on main timeline pls solve this

function reverse(init) {
init.stop();
var noofframes = init._totalframes;
var i = noofframes;
while(i < 1){
init.gotoAndPlay(i);
i–;
if(i==1)
i = noofframes;
}
trace(i);

}

the function isn’t working pls check it