# Forward and back between two frames at the press of a button

**URL:** <https://forum.kirupa.com/t/forward-and-back-between-two-frames-at-the-press-of-a-button/211231>\
**Category:** Uncategorized\
**Created:** [December 28, 2006, 9:30pm UTC](https://forum.kirupa.com/t/forward-and-back-between-two-frames-at-the-press-of-a-button/211231 "2006-12-28T21:30:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalewb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dalewb/32/3029_2.png) [@dalewb](https://forum.kirupa.com/u/dalewb)\
**Post date:** [December 28, 2006, 9:30pm UTC](https://forum.kirupa.com/t/forward-and-back-between-two-frames-at-the-press-of-a-button/211231/1 "2006-12-28T21:30:22Z")

</div>

In the continuing evolution of my code, I simply want a button to alternate moving the playhead backwards and forwards along the timeline between frames 1 and 17. This code is not working. Any ideas? I have attached a screen capture to clarify your questions in advance 🙂

```auto

on(press){
    var targetFrame = _parent._currentframe;
    //enter username
    if (targetFrame == 1){
        _parent.play();
    }
    //enter password
    else if(targetFrame == 17){
        for (var i:Number = 0; i<16; i++){
            _parent.prevFrame();
            trace(_parent._currentframe);            
        }
    }
    trace("Frame number=" + targetFrame)
}

```
