Copy link to clipboard
Copied
i have mc on stage called team which has 11 children "(players[myNum])" that are randomly triggered by button called "caller".
what script do i have to add to function"calling" in order to bring the randomly child to front?
stop()
var players:Array = [team.christian,team.danny,team.davinson,team.dele,team.harry,team.heung,team.hugo,team.jan,team.kieran,team.moussa,
team.tanguy]
var chosen
var picture
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
team.addEventListener(TouchEvent.TOUCH_BEGIN, BeginHandler);
team.addEventListener(TouchEvent.TOUCH_END, EndHandler);
caller.addEventListener(TouchEvent.TOUCH_BEGIN, calling);
var orech:Number=11;
var DragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
function calling(event:TouchEvent):void
{
var myNum:Number = Math.floor(Math.random()*orech);
orech= orech-1;
players[myNum].x=200;
players[myNum].y=750;
this is the place i want to add the bring to front script
caller.x=1200
........
chosen=players[myNum];
players.splice(myNum,1)
if (orech==0)
{
gotoAndStop(2)
}
}
function BeginHandler(event:TouchEvent):void
{
event.target.startTouchDrag(event.touchPointID, false, DragBounds);
event.target.width=135
event.target.height=135
}
function EndHandler(event:TouchEvent):void
{
event.target.stopTouchDrag(event.touchPointID);
if (chosen.hitTestPoint(picture.x,picture.y)) {
......
melel.text="wrong"
chosen.x=200;
chosen.y=750;
chosen.width=290
chosen.height=295
}
}
function calling(event:TouchEvent):void
{
var myNum:Number = Math.floor(Math.random()*orech);
orech= orech-1;
players[myNum].x=200;
players[myNum].y=750;
bringTo FrontF(players[myNum]);
.
.
.
}
function bringToFrontF(mc:MovieClip):void{
if(mc.stage){
mc.parent.addChild(mc);
}
}
Copy link to clipboard
Copied
function calling(event:TouchEvent):void
{
var myNum:Number = Math.floor(Math.random()*orech);
orech= orech-1;
players[myNum].x=200;
players[myNum].y=750;
bringTo FrontF(players[myNum]);
.
.
.
}
function bringToFrontF(mc:MovieClip):void{
if(mc.stage){
mc.parent.addChild(mc);
}
}
Copy link to clipboard
Copied
thank you
Copy link to clipboard
Copied
you're welcome.