# Working with array

**URL:** https://forum.kirupa.com/t/working-with-array/301216
**Category:** Uncategorized
**Created:** [December 5, 2009, 8:00am UTC](https://forum.kirupa.com/t/working-with-array/301216 "2009-12-05T08:00:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![paglaiori](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@paglaiori](https://forum.kirupa.com/u/paglaiori)
#### Post date: [December 5, 2009, 8:00am UTC](https://forum.kirupa.com/t/working-with-array/301216/1 "2009-12-05T08:00:37Z")

</div>

thanks in advance,  
i have created 4 movie clips and named (instance) them box1, box2, box3, box4 and shuffled them with the following code:

var vector\_name:Array = new Array(“box1”, “box2”, “box3”, “box4”);

function shuffle(a,b):Number  
{  
var num : Number = Math.round(Math.random()\*2)-1;  
return num;  
}  
var shuffled\_vector:Array = vector\_name.sort(shuffle);  
trace(shuffled\_vector);

- question is, how can i tween the instances using fl.transitions.Tween with a loop.
- i tried the following but did not work… ☹

btnPlay.addEventListener(MouseEvent.CLICK, startMotion);

function startMotion(me:MouseEvent):void  
{  
btnPlay.visible = false;  
for(var j:int = 0; j \< 4; j++)  
{  
var twSlide:Tween;  
var box = new MovieClip();  
box = shuffled\_vector[j];  
twSlide = new Tween(box, “x”, Back.easeOut, 100+50\*j, 100, 10);  
}  
}
