# Help on stage.focus

**URL:** <https://forum.kirupa.com/t/help-on-stage-focus/299092>\
**Category:** Uncategorized\
**Created:** [October 29, 2009, 4:12pm UTC](https://forum.kirupa.com/t/help-on-stage-focus/299092 "2009-10-29T16:12:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![perconte](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@perconte](https://forum.kirupa.com/u/perconte)\
**Post date:** [October 29, 2009, 4:12pm UTC](https://forum.kirupa.com/t/help-on-stage-focus/299092/1 "2009-10-29T16:12:54Z")

</div>

Please help! Simple question. There are 5 movieclips on the stage (btn0 to btn4). I wanted to change focus pressing Keyboard.UP and Keyboard.DOWN. But the focus changes not in correct order. It jumps in mysterious way from 0 to 2 and so on. Please help!!! In case, .fla file is in attachment.

```php

stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);

//hold active position
var activeElem:uint=0;

btn0.tabIndex=0;
btn1.tabIndex=1;
btn2.tabIndex=2;
btn3.tabIndex=3;
btn4.tabIndex=4;

//set focus on firs btn
setFocusOn(0);

function setFocusOn(id:uint):void {
    var tempMc:MovieClip = MovieClip(this.getChildByName("btn"+id));
    trace("tempMc= "+tempMc.name+ " at index="+tempMc.tabIndex);
    stage.focus = tempMc;
    trace("focus on= "+stage.focus.name);
    trace("------");
}

function reportKeyDown(event:KeyboardEvent):void {
    switch (event.keyCode) {
        case Keyboard.UP :
            if (activeElem>0) {
                trace("up");
                activeElem--;
                setFocusOn(activeElem);
            }
            break;
        case Keyboard.DOWN :
            if (activeElem<4) {
                trace("down");
                activeElem++;
                setFocusOn(activeElem);
            }
    }
}

```
