# Change Arrangement of objects!

**URL:** <https://forum.kirupa.com/t/change-arrangement-of-objects/263409>\
**Category:** flash\
**Created:** [June 15, 2008, 7:45pm UTC](https://forum.kirupa.com/t/change-arrangement-of-objects/263409 "2008-06-15T19:45:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anix](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anix](https://forum.kirupa.com/u/anix)\
**Post date:** [June 15, 2008, 7:45pm UTC](https://forum.kirupa.com/t/change-arrangement-of-objects/263409/1 "2008-06-15T19:45:09Z")

</div>

hi i am designing a portfolio website and i have multiple objects that are positioned on top of each other and on CLICK events there alpha rises to be visible but i also want to arrange them to be the object at the very FRONT of the other objects on the stage so that the mouse overs for them function correctly. and i wondered if there was a way to change the arrangement of an item on stage to bring it to the FRONT via actionscript? thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![anix](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anix](https://forum.kirupa.com/u/anix)\
**Post date:** [June 15, 2008, 8:39pm UTC](https://forum.kirupa.com/t/change-arrangement-of-objects/263409/2 "2008-06-15T20:39:19Z")

</div>

i think it might have sommit to do with switching the depths of the items but im not sure how to do that in actionscript 3 lol!

---

<div class="post-metadata">

**Author:** ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)\
**Post date:** [June 16, 2008, 12:25am UTC](https://forum.kirupa.com/t/change-arrangement-of-objects/263409/3 "2008-06-16T00:25:33Z")

</div>

This script sets the event.target as the top-most object.

The relevant code is in the MOUSE\_OVER function:  
[COLOR=“Blue”]buttonGroup.setChildIndex(event.target as MovieClip, buttonGroup.numChildren-1);[/COLOR]

[QUOTE=anix;2343230]i think it might have sommit to do with switching the depths of the items but im not sure how to do that in actionscript 3 lol![/QUOTE]

```auto
stop();
import gs.TweenMax;
import fl.motion.easing.*;

buttonGroup.addEventListener(MouseEvent.MOUSE_OVER, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.MOUSE_OUT, action, false, 0, true);
buttonGroup.addEventListener(MouseEvent.CLICK, action, false, 0, true);
buttonGroup.mouseEnabled = false;

var button:String = "";

function action(event:MouseEvent):void {
	button = event.target.name;
	switch (event.type) {
		case MouseEvent.MOUSE_OVER :
			buttonGroup.setChildIndex(event.target as MovieClip, buttonGroup.numChildren-1);
			TweenMax.to(event.target, 2, {scaleX:1.5, scaleY:1.5, ease:Elastic.easeOut});
			break;
		case MouseEvent.MOUSE_OUT :
			TweenMax.to(event.target, 2, {scaleX:1, scaleY:1, ease:Elastic.easeOut});
			break;
		case MouseEvent.CLICK :
			TweenMax.to(event.target, .5, {scaleX:1, scaleY:1, ease:Cubic.easeOut});
			break;
	}
}

```
