12

I have a menu set up that has about 20 menu items in a circle. When you mouse over each item, a title comes up. The only problem is that because of the depth order, it's hidden behind the other menu items. Is there a way to bring this item to the front when moused over? I'm pretty actionscript illiterate so any help would be awesome.

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
steve
  • 688
  • 6
  • 13
  • 32

2 Answers2

21

If you don't want your object being removed and then added to the display list using addChild you can use setChildIndex

var parent:DisplayObjectContainer = myElement.parent;
parent.setChildIndex(myElement, parent.numChildren-1);
Patrick
  • 15,702
  • 1
  • 39
  • 39
1

You can move an item to the top by re-adding it to the display list, using addChild(item), even if it is already added as a child. Something in the lines of this:

function onMouseOver(e:MouseEvent) {
    e.target.parent.addChild(e.target);
}

It may feel a bit odd to use this approach, instead of other possible methods to move stuff around in a display list, but since addChild(object) first removes the object from a display list, before adding it, it will work just fine.

Lars Blåsjö
  • 6,118
  • 2
  • 19
  • 23