# Back and forward using arrays

**URL:** <https://forum.kirupa.com/t/back-and-forward-using-arrays/30985>\
**Category:** Uncategorized\
**Created:** [September 17, 2003, 12:31am UTC](https://forum.kirupa.com/t/back-and-forward-using-arrays/30985 "2003-09-17T00:31:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sliddick](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sliddick](https://forum.kirupa.com/u/sliddick)\
**Post date:** [September 17, 2003, 12:31am UTC](https://forum.kirupa.com/t/back-and-forward-using-arrays/30985/1 "2003-09-17T00:31:09Z")

</div>

i found a tech note on macromedia about creating a back button within flash, and using an array to “remember” your history. it works really well, but my question is, how would one alter it to add a forward button.

here is the code from the tech document.

[http://www.macromedia.com/support/flash/ts/documents/swf\_back\_button.htm](http://www.macromedia.com/support/flash/ts/documents/swf_back_button.htm)

in my project, let’s say i have 4 keyframes on the main timeline. on the first frame, this code appears:

navStack = [];

on the next 3 frames, this code appears:

navStack.push(\_currentFrame);

on the stage there is a button with this code on it.

on (release) {  
if (\_root.navStack.length \> 1) {  
recentFrame = \_root.navStack.pop();  
previousFrame = \_root.navStack.pop();  
goToAndPlay(previousFrame);  
trace(navStack);  
}  
}

i’ve added the trace and you can see how it works. pretty slick. i’d like to add a forward button. anyone have any examples or thoughts on how to approach this.

thanks.
