Action scripting back button

im having some trouble with my code, the right key button works fine but if you press the left key it just goes to the next frame? may be i need to add something eles in on the stop frames other than stop(); ?


var myListener:Object = new Object();
myListener.onKeyDown = function () {
    if (Key.isDown(Key.RIGHT)) {
        gotoAndPlay("next");
 
    }
}
Key.addListener(myListener);
var myListener:Object = new Object();
myListener.onKeyDown = function () {
    if (Key.isDown(Key.LEFT)) {
        gotoAndPlay("previous");
 
    }
}
Key.addListener(myListener);

any one have any idea thanks Martin

I had the same problem…i found this in kirupa tutorials, with some small changes you can rewind the animation.

here it is the tutorials:
http://www.kirupa.com/developer/mx2004/button_effect.htm

the main idea it’s to put the rewind function into a function, that it’s everytime called so you play one frame back everytime you rollover (or you are already with the mouse over) the button.

Thanks but i dont think it will work in my case, sorry i should of explained my self better basicly what i have is a slide show as such, and it play and loops on the stop frame untill your press the right arrow key then it goes and plays and loops again untill the next stop key. but when you press the left arrow key it doesnt go back to the previous stop action it goes next,

go on www.imagine-hamburg.de on the referenzen page, and say if that it is what you are looking for!

not really, but on the first page once u click it goes to the main page but if u right click it has a rewind button and goes and play the first scene again thats somthing what i want best way to think of it, is its a powerpoint presentation where u can press the mouse to go to the next frame and also to goto the previous frame

In this code:


var myListener:Object = new Object();
myListener.onKeyDown = function () {
    if (Key.isDown(Key.RIGHT)) {
        gotoAndPlay("next");
 
    }
}
Key.addListener(myListener);
var myListener:Object = new Object();
myListener.onKeyDown = function () {
    if (Key.isDown(Key.LEFT)) {
        gotoAndPlay("previous");
 
    }
}
Key.addListener(myListener);

flash doesn’t know what to do, because u have same variables and functions. try to change the name of the variables and function. so for the right you have myListenerR and for the left you have myListenerL. Here i see a first problem.

var myListener:Object = new Object();
Key.addListener(myListener);
myListener.onKeyDown = function () {
    if (Key.isDown(Key.RIGHT)) {
        gotoAndPlay("next"); 
    } else if (Key.isDown(Key.LEFT)) {
        gotoAndPlay("previous"); 
    }
}

Your code is a bit… excessive. As for your issue didnt check it out… but this is allthe code you need :thumb:

:slight_smile: cool thats neater thanks but still having my problem :frowning: