# Random position+tween

**URL:** <https://forum.kirupa.com/t/random-position-tween/211804>\
**Category:** Uncategorized\
**Created:** [January 5, 2007, 6:43am UTC](https://forum.kirupa.com/t/random-position-tween/211804 "2007-01-05T06:43:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joakinrox](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@joakinrox](https://forum.kirupa.com/u/joakinrox)\
**Post date:** [January 5, 2007, 6:43am UTC](https://forum.kirupa.com/t/random-position-tween/211804/1 "2007-01-05T06:43:15Z")

</div>

[COLOR=Red][COLOR=Black]Ok plz ive been burning my head for the last week trying to figure this out but i cant!.. ok so basicly what i have in the stage is a puzzle already solved. each piece of the puzzle is a movie clip. so the idea is that when i put this code in each of the pieces of the puzzle when i start the movie… each pieces should appear in a random position outside the stage and then using a random tween, easing, rotation and a timing a bit different to the position it belongs to inside the puzzle… (the final position of all pieces is the one i have on the first frame of the movie)

so… this crap is all ive got so far… the only thing i nailed is the ramdom position at the beggining (and thats because a guy from here (i think his name was canadian) really helped me lol …thx!)

plz help!!! =D and sorry for my bad english/spelling or whatever is wrong with the text xd  
im using flash 8  
[/COLOR]  
onClipEvent (load) {  
import mx.transitions.Tween;  
import mx.transitions.easing.\*;  
num = Math.round(Math.random()\*3);  
this.\_alpha= Math.round(Math.random()\*100)  
switch (num) {  
case 0:  
Array1 = new Array(-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450,500, 550, 600, 650, 700, 750);  
this.\_x= -100  
this.\_y= Array1[Math.floor(Math.random() \* Array1.length)];  
break;  
case 1:  
Array2 = new Array(-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450,500, 550, 600, 650, 700, 750);  
this.\_x= 600  
this.\_y= Array2[Math.floor(Math.random() \* Array2.length)];  
break;  
case 2:  
Array3 = new Array(-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450,500, 550, 600, 650, 700, 750);  
this.\_y= -100  
this.\_x= Array3[Math.floor(Math.random() \* Array3.length)];  
break;  
case 3:  
Array4 = new Array(-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450,500, 550, 600, 650, 700, 750);  
this.\_y= 600  
this.\_x= Array4[Math.floor(Math.random() \* Array4.length)];  
break;  
default:  
this.\_x= 1  
this.\_y= 1  
}  
ease = new Array(Bounce, Back, Elastic, None, Regular, Strong);  
method = new Array(“easeIn”, “easeOut”, “easeInOut”);  
randEase = ease[Math.floor(Math.random() \* ease.length)][method[Math.floor(Math.random() \* method.length)]];

new Tween(azul\_mc,"\_x",randEase,this.\_x,102,5,true);  
new Tween(azul\_mc,"\_y",randEase,this.\_y,40.9,5,true);  
new Tween(azul\_mc,“alpha”,randEase,this.\_alpha,100,5,true);  
}[/COLOR]
