# AS3 Movieclip always on top!

**URL:** <https://forum.kirupa.com/t/as3-movieclip-always-on-top/283299>\
**Category:** flash\
**Created:** [March 4, 2009, 5:21pm UTC](https://forum.kirupa.com/t/as3-movieclip-always-on-top/283299 "2009-03-04T17:21:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artheus](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@artheus](https://forum.kirupa.com/u/artheus)\
**Post date:** [March 4, 2009, 5:21pm UTC](https://forum.kirupa.com/t/as3-movieclip-always-on-top/283299/1 "2009-03-04T17:21:23Z")

</div>

Hey!

I’ve been trying a while now making a cursor in AS3 that stays on top all the time… But it’s hard…

cursor = the cursor MovieClip.

```auto

Mouse.hide();

cursor.addEventListener(Event.ENTER_FRAME, cursorEvent);

function cursorEvent(e:Event) {
    cursor.x = mouseX;
    cursor.y = mouseY;
}

```

I’ve seen some places that it’s easy, just to add “setChildIndex()”.  
But i’ve not gotten it to work properly.

This is what i’ve tried :

```auto

Mouse.hide();

cursor.setChildIndex(cursor, 9999)

cursor.addEventListener(Event.ENTER_FRAME, cursorEvent);

function cursorEvent(e:Event) {
    cursor.x = mouseX;
    cursor.y = mouseY;
}

```

and

```auto

Mouse.hide();

this.setChildIndex(cursor, 9999)

cursor.addEventListener(Event.ENTER_FRAME, cursorEvent);

function cursorEvent(e:Event) {
    cursor.x = mouseX;
    cursor.y = mouseY;
}

```

And i’ve tried stage instead of cursor and this too…

What am I doing wrong?

Cheers,  
Artheus
