# Works on ActionScript 1.0 but not on ActionScript 2.0

**URL:** <https://forum.kirupa.com/t/works-on-actionscript-1-0-but-not-on-actionscript-2-0/83905>\
**Category:** flash\
**Created:** [March 23, 2005, 1:59am UTC](https://forum.kirupa.com/t/works-on-actionscript-1-0-but-not-on-actionscript-2-0/83905 "2005-03-23T01:59:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzisaacs](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@dzisaacs](https://forum.kirupa.com/u/dzisaacs)\
**Post date:** [March 23, 2005, 1:59am UTC](https://forum.kirupa.com/t/works-on-actionscript-1-0-but-not-on-actionscript-2-0/83905/1 "2005-03-23T01:59:13Z")

</div>

The following code works if you have your flash file set to:  
Flash Player 6  
Action Script 1

I need it to work for  
Flash Player 7  
Action Script 2

What it does is that basically if i have  
1 2 3 4 5  
and i click on the 5 it will arrange the movie clips so they will be  
5 1 2 3 4

mc is the name for action script of the movie clip i’m using

I think  
the function that doesn’t work correctly is the move function

var acceleration = 12;  
var friction = 0.7;  
clipArray = [];  
posArray = [];  
for (var k = 0; k\<5; k++) {  
myclip = attachMovie(“mc”, “mc”+k, k);  
myclip.\_y = 100;  
myclip.\_x = 170+myclip.\_width\*k;  
[//myclip.myText.text](https://myclip.myText.text) = "Button "+k;  
clipArray.push(myclip);  
[//countArray.push](https://countArray.push)(k);  
posArray.push(myclip.\_x);  
myclip.onPress = dostuff;  
}  
function move() {  
var xdif = posArray[this.jvar]-this.\_x;  
this.xspeed += xdif/this.\_parent.acceleration;  
this.xspeed \*= this.\_parent.friction;  
this.\_x += this.xspeed;  
this.checkDistance();

}  
checkDistance = function () {  
if (Math.abs(posArray[this.jvar]-this.\_x)\<1) {  
this.\_x = posArray[this.jvar];  
delete this.onEnterFrame;  
}  
};  
function dostuff() {  
for (var i = 0; i\<clipArray.length; i++) {  
// setting indexes  
clipArray\*.ivar = i;;  
}  
// deleting the mc the user clicked  
k = clipArray.splice(this.ivar, 1);

```
// the mc you click is on the front
clipArray = k.concat(clipArray);

for (var j = 0; j&lt;posArray.length; j++) {
    // re setting the indexes
    clipArray[j].jvar = j;
    trace(clipArray[j]+" "+clipArray[j].jvar);
    // calls move
    clipArray[j].onEnterFrame = move;
}

```

}
