Hi.
If I'm understanding what you want, you need to store the final frame of your animation in a property or variable. Then when the user presses the button, you change the value of this property or variable. Like this:
HTML5 Canvas:
Main timeline / frame 1 (0):
var root = this;
root.endFrame = 9; // in HTML5 documents the first frame index is 0 so the 10th frame index is 9
root.stopLoop = function(e)
{
root.endFrame = 19;
};
root.yourButton.on("click", root.stopLoop);
Main timeline / frame 10 (9):
this.gotoAndPlay(this.endFrame);
AS3:
Main timeline / frame 1:
import flash.events.MouseEvent;
var endFrame:uint = 10;
function stopLoop(e:MouseEvent):void
{
endFrame = 20;
}
yourButton.addEventListener(MouseEvent.CLICK, stopLoop);
Main timeline / frame 10:
gotoAndPlay(endFrame);
Please let us know if this is what you want.
Regards,
JC