Preloader problem

For a preloader where an 100 frames movie advances as it loads, I used these actions:

stop();
onEnterFrame = function ()
{totalBytes = _root.getBytesTotal();
loadedBytes = _root.getBytesLoaded();
percent = Math.ceil((loadedBytes/totalBytes)*100);
_root.<<the instance>>.gotoAndStop(percent);
if (percent=100)
{play();
}
};

If there’s a stop action in a later frame, it is ignored. If I use gotoAndStop(x) instead, if there’s a play button at that frame, it won’t work. What should I do?