Tracking currentFrame and storing it

How would you code this in AS3?

I want a set of 2 buttons. One button would be a nextBtn, that would mover the user forward one frame, and the other would be a homeBtn that would take them back to frame one.

What I want to do is track what frame they are on (say frame 5) so that if they click the homeBtn and go back to frame 1, they could later click the nextBtn and now instead of going to the nextFrame they would go back to whatever frame they were on (which was 5).

Hope that makes sense. Here is was I was working on but I don’t know how to store the frame the user left on.


nextBtn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

function fl_ClickToGoToNextFrame(event:MouseEvent):void
{
	var frame:Number;
	frame = currentFrame;
	frameTxt.text = (String(frame));
	trace(frame);
	gotoAndStop(1 + frame);
}

homeBtn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame2);

function fl_ClickToGoToNextFrame2(event:MouseEvent):void
{
	gotoAndStop(1);
}