I want to randomly tween a Child into stage’s border. Code works well, but I think there can be found a better soultion
var point:Point=this.buttonContainer.globalToLocal(new Point(stage.stageWidth / 2,stage.stageHeight / 2))
for (var i:int=0;i<this.buttonContainer.numChildren;i++) {
var array=[[[this.buttonContainer.globalToLocal(new Point(0,0)).x,this.buttonContainer.globalToLocal(new Point(stage.stageWidth,0)).x],this.buttonContainer.globalToLocal(new Point(0,stage.stageHeight)).y],[this.buttonContainer.globalToLocal(new Point(stage.stageWidth,0)).x,[this.buttonContainer.globalToLocal(new Point(0,0)).y,this.buttonContainer.globalToLocal(new Point(0,stage.stageHeight)).y]]];
temp=array[Math.round(Math.random())]
//trace(temp[0] is Array?temp[0][Math.round(Math.random())]:Math.random() * temp[0])
///trace(temp[1] is Array?temp[1][Math.round(Math.random())]:Math.random() * temp[1])
var child:DisplayObject=this.buttonContainer.getChildAt(i);
TweenMax.to(child,5,{x:temp[0] is Array?temp[0][Math.round(Math.random())]:Math.random() * temp[0],y:temp[1] is Array?temp[1][Math.round(Math.random())]:Math.random() * temp[1],delay:i / 50,autoAlpha:1,ease:Regular.easeInOut});//,bezier:[{x:point.x,y:point.y}]
}