krashe1313
07-01-2009, 12:18 PM
Hello,
I'm back and working on teaching myself more AS3 to expand on the stuff i've learned already and the great advice you've given me in the past, in the down between projects.
so here's what i'm trying to do. simple. making a small "game" as an exercise. I currently have 4 boxes (blue, red, green, purple) on the screen. Each an instance of box_mc, instance named "boxMC", "boxMC1", etc.
You can drag each of them around. That works.
My question is that when i click on a box, I would like to set the Z-order to the top most layer and could be dragged over, and let go, the others. I used the setChildIndex, but I can only apply it to just a particular instance...
setChildIndex(boxMC2, numChildren-1);
...but not dependent on which the box that is being clicked. This is what I'm currently trying, but with no luck:
function initDragger(mc:MovieClip):void
{
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
setChildIndex(mc, numChildren -1);
//trace(numChildren);
}
function mouseDownHandler(event:MouseEvent):void
{
event.currentTarget.startDrag();
}
function mouseUpHandler(event:MouseEvent):void
{
event.currentTarget.stopDrag();
}
// Set up drag
initDragger(boxMC);
initDragger(boxMC1);
initDragger(boxMC2);
initDragger(boxMC3);
any help would be great! thank you very much in advance!
`shields
I'm back and working on teaching myself more AS3 to expand on the stuff i've learned already and the great advice you've given me in the past, in the down between projects.
so here's what i'm trying to do. simple. making a small "game" as an exercise. I currently have 4 boxes (blue, red, green, purple) on the screen. Each an instance of box_mc, instance named "boxMC", "boxMC1", etc.
You can drag each of them around. That works.
My question is that when i click on a box, I would like to set the Z-order to the top most layer and could be dragged over, and let go, the others. I used the setChildIndex, but I can only apply it to just a particular instance...
setChildIndex(boxMC2, numChildren-1);
...but not dependent on which the box that is being clicked. This is what I'm currently trying, but with no luck:
function initDragger(mc:MovieClip):void
{
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
setChildIndex(mc, numChildren -1);
//trace(numChildren);
}
function mouseDownHandler(event:MouseEvent):void
{
event.currentTarget.startDrag();
}
function mouseUpHandler(event:MouseEvent):void
{
event.currentTarget.stopDrag();
}
// Set up drag
initDragger(boxMC);
initDragger(boxMC1);
initDragger(boxMC2);
initDragger(boxMC3);
any help would be great! thank you very much in advance!
`shields