# Action scripting back button

**URL:** <https://forum.kirupa.com/t/action-scripting-back-button/186023>\
**Category:** Uncategorized\
**Created:** [April 18, 2006, 2:29pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023 "2006-04-18T14:29:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [April 18, 2006, 2:29pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/1 "2006-04-18T14:29:38Z")

</div>

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(); ?

```auto

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

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 18, 2006, 2:35pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/2 "2006-04-18T14:35:45Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [April 18, 2006, 2:49pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/3 "2006-04-18T14:49:39Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 18, 2006, 2:52pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/4 "2006-04-18T14:52:08Z")

</div>

go on [www.imagine-hamburg.de](http://www.imagine-hamburg.de) on the referenzen page, and say if that it is what you are looking for!

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [April 18, 2006, 2:59pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/5 "2006-04-18T14:59:28Z")

</div>

> [@btibia](#):
>
> go on [www.imagine-hamburg.de](http://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

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 18, 2006, 3:04pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/6 "2006-04-18T15:04:27Z")

</div>

In this code:

```auto

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.

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 18, 2006, 11:18pm UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/7 "2006-04-18T23:18:32Z")

</div>

```auto
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:

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [April 19, 2006, 10:26am UTC](https://forum.kirupa.com/t/action-scripting-back-button/186023/8 "2006-04-19T10:26:00Z")

</div>

> [@nathan99](#):
>
> ActionScript Code:  
> [FONT=Courier New][LEFT][COLOR=#000000] **var** [/COLOR] myListener:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000[/COLOR];\</p\>  
> \<p\>Key.[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];\</p\>  
> \<p\>myListener.[COLOR=#0000ff]onKeyDown[/COLOR] = [COLOR=#000000] **function** [/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
> \<p\> [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
> \<p\> [COLOR=#0000ff]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR]; \</p\>  
> \<p\> [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
> \<p\> [COLOR=#0000ff]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR]; \</p\>  
> \<p\> [COLOR=#000000]}[/COLOR]\</p\>  
> \<p\>[COLOR=#000000]}[/COLOR]  
> [/LEFT]  
> [/FONT]
> 
> Your code is a bit… excessive. As for your issue didnt check it out… but this is allthe code you need :thumb:

🙂 cool thats neater thanks but still having my problem ☹
