;

PDA

Click to See Complete Forum and Search --> : layering my buttons to the top level!


ratboy
04-17-2009, 12:50 PM
On mouseover i'm trying to get my selected button to come to the top of the display list of buttons.

the code below is my latest effort which does not work.

function mouseOverHandler (e:Event):void {
this.setChildIndex(e.target,this.numChildren - 1);
}

any idea where i go from here?

rat

cancerinform
04-17-2009, 01:13 PM
replace with this:
swapChildren(Button(e.currentTarget),Button(getChi ldAt(numChildren-1)));

use Button for the Button component and MovieClip for MovieClip buttons

5TonsOfFlax
04-17-2009, 01:18 PM
You could try something like this:

function mouseOverHandler (e:Event):void {
DisplayObject(e.target).parent.addChild(e.target);
}


addChild has an interesting quirk in that it puts things at the top of the list of display children. Combine this with the fact that it also removes the thing from any other displayList it was already on, and you get the "move-to-top" behavior you're looking for.

ratboy
04-17-2009, 01:28 PM
I keep getting this error whatever i seem to do!!!!


1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

5TonsOfFlax
04-17-2009, 01:32 PM
You may have to use the cast version again in the addChild call. I believe the thing you posted is a warning rather than an error.

function mouseOverHandler (e:Event):void {
var targ:DisplayObject = DisplayObject(e.target);
targ.parent.addChild(targ);
}

ratboy
04-20-2009, 06:42 AM
that has done the trick.

thank you