Rewind Button AS3

Hi all

First off, I´m fairly new to Actionscript, but I understand the basics.

What I´m trying to do is to create buttons that acts like the buttons on

However, they are activated from an external swf, but I would like to have them static on my timeline.

The code I have so far is something in the ways like this.


hitArea.buttonMode = true;

var hrewind:Boolean = false;
hitArea.addEventListener(Event.ENTER_FRAME, rewindButton);
hitArea.addEventListener(MouseEvent.MOUSE_OVER, playButton);
hitArea.addEventListener(MouseEvent.MOUSE_OUT, startRewind);

function rewindButton(event:Event){
if(hrewind) prevFrame();
function playButton(event:MouseEvent){
hrewind = false;
function startRewind(event:MouseEvent){
hrewind = true;

It works out okay, but when I add another button using the same script it rewinds all the way do the starting frame, resulting in making the first button rewind itself after the second button, as it rewinds back in the timeline.

Can someone help me get around this problem, or point me in the correct way if I have written something wrong in the code or misunderstood the whole concept of rewinding buttons.

Thanks in advance.