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 = "Button "+k;
clipArray.push(myclip);
//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<posArray.length; j++) {
// re setting the indexes
clipArray[j].jvar = j;
trace(clipArray[j]+" "+clipArray[j].jvar);
// calls move
clipArray[j].onEnterFrame = move;
}
}