# \[FMX\] Random easing

**URL:** https://forum.kirupa.com/t/fmx-random-easing/59488
**Category:** flash
**Created:** [August 1, 2004, 7:17am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488 "2004-08-01T07:17:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 1, 2004, 7:17am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/1 "2004-08-01T07:17:21Z")

</div>

I have a picture on the stage covered by 12 squares (sq1, sq2, sq3…sq12)  
When the movie opens I want the squares to move down, but i want a random sequence ( 3, 9, 2, 12…8). I already made de function for the movement:

```auto
function moveClip(clip, ypos, snelheid) {
 clip.onEnterFrame = function() {
  var endY = ypos - this._y;
  this._y += endY / snelheid;
  if (Math.abs(endY)<2) {
   this._y = ypos;
   delete this.onEnterFrame;
  }
 };
}

```

But I don’t now how to move the differens squares random with a interval from lets say .300.

Anybody?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 8:30am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/2 "2004-08-01T08:30:59Z")

</div>

[QUOTE=dboers]I have a picture on the stage covered by 12 squares (sq1, sq2, sq3…sq12)  
When the movie opens I want the squares to move down, but i want a random sequence ( 3, 9, 2, 12…8). I already made de function for the movement:

```auto
function moveClip(clip, ypos, snelheid) {
 clip.onEnterFrame = function() {
  var endY = ypos - this._y;
  this._y += endY / snelheid;
  if (Math.abs(endY)<2) {
   this._y = ypos;
   delete this.onEnterFrame;
  }
 };
}

```

something like this might work  
myArray = [];  
j = 0;  
for (i=1; i\<13; i++) {  
this[“sq”+i].ypos = this[“sq”+i].\_y+100;  
myArray.push(this[“sq”+i]);  
}  
shuffle = function () {  
return Math.round(Math.random());  
};  
// randomizes array  
myArray.sort(shuffle);  
function moveClip(clip, snelheid) {  
clip.\_y += (clip.ypos-clip.\_y)/snelheid;  
if (Math.abs(clip.ypos-clip.\_y)\<2) {  
clip.\_y = clip.ypos;  
clearInterval(myInterval);  
if (j\<myArray.length-1) {  
j += 1;  
myinterval = setInterval(moveClip, 20, myArray[j], 20);  
} else {  
trace(“finished”);  
}  
}  
}  
myinterval = setInterval(moveClip, 20, myArray[j], 20);

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 8:48am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/3 "2004-08-01T08:48:45Z")

</div>

> [@stringy](#):
>
> [QUOTE=dboers]I have a picture on the stage covered by 12 squares (sq1, sq2, sq3…sq12)  
> When the movie opens I want the squares to move down, but i want a random sequence ( 3, 9, 2, 12…8). I already made de function for the movement:
> 
> ```auto
> function moveClip(clip, ypos, snelheid) {
> clip.onEnterFrame = function() {
> var endY = ypos - this._y;
> this._y += endY / snelheid;
> if (Math.abs(endY)<2) {
> this._y = ypos;
> delete this.onEnterFrame;
> }
> };
> }
> 
> ```
> 
> something like this might work  
> myArray = ;  
> j = 0;  
> for (i=1; i\<13; i++) {  
> this[“sq”+i].ypos = this[“sq”+i].\_y+100;  
> myArray.push(this[“sq”+i]);  
> }  
> shuffle = function () {  
> return Math.round(Math.random());  
> };  
> // randomizes array  
> myArray.sort(shuffle);  
> function moveClip(clip, snelheid) {  
> clip.\_y += (clip.ypos-clip.\_y)/snelheid;  
> if (Math.abs(clip.ypos-clip.\_y)\<2) {  
> clip.\_y = clip.ypos;  
> clearInterval(myInterval);  
> if (j\<myArray.length-1) {  
> j += 1;  
> myinterval = setInterval(moveClip, 20, myArray[j], 20);  
> } else {  
> trace(“finished”);  
> }  
> }  
> }  
> myinterval = setInterval(moveClip, 20, myArray[j], 20);

This might give you a little more control

myArray = ;  
j = 0;  
for (i=1; i\<13; i++) {  
this[“sq”+i].ypos = this[“sq”+i].\_y+100;  
myArray.push(this[“sq”+i]);  
}  
shuffle = function () {  
return Math.round(Math.random());  
};  
// randomizes jokes array  
myArray.sort(shuffle);  
function moveClip(clip, snelheid) {  
clip.onEnterFrame = function() {  
clip.\_y += (clip.ypos-clip.\_y)/snelheid;  
if (Math.abs(clip.ypos-clip.\_y)\<2) {  
clip.\_y = clip.ypos;  
delete clip.onEnterFrame;  
}  
};  
}  
function startoff() {  
if (j\<myArray.length) {  
moveClip(myArray[j], 10);  
j++;  
} else {  
clearInterval(myinterval);  
trace(“finished”);  
}  
}  
myinterval = setInterval(startOff, 300);

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 9:02am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/4 "2004-08-01T09:02:26Z")

</div>

Thanks a lot stringy 🙂 That works perfect. I only can’t figure out how to change the distance from the movements. The squares have an height of 360 pixels with the registration point top, so they have to move 360 pixels down

Thanks in advance 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 9:24am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/5 "2004-08-01T09:24:10Z")

</div>

> [@dboers](#):
>
> Thanks a lot stringy 🙂 That works perfect. I only can’t figure out how to change the distance from the movements. The squares have an height of 360 pixels with the registration point top, so they have to move 360 pixels down
> 
> Thanks in advance 🙂

you just need to change 100 in this line  
this[“sq”+i].ypos = this[“sq”+i].\_y+100;

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 9:51am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/6 "2004-08-01T09:51:36Z")

</div>

> [@stringy](#):
>
> you just need to change 100 in this line  
> this[“sq”+i].ypos = this[“sq”+i].\_y+100;

Thanks a lot:thumb:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 1, 2004, 9:52am UTC](https://forum.kirupa.com/t/fmx-random-easing/59488/7 "2004-08-01T09:52:27Z")

</div>

> [@dboers](#):
>
> Thanks a lot:thumb:

welcome
