Works on ActionScript 1.0 but not on ActionScript 2.0

  • dzisaacs
  • Born
  • Born
  • dzisaacs
  • Posts: 1

Post 3+ Months Ago

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

HOW CAN I FIX THIS :(

Code: [ Select ]
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[i].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;
}
}
  1. var acceleration = 12;
  2. var friction = 0.7;
  3. clipArray = [];
  4. posArray = [];
  5. for (var k = 0; k<5; k++) {
  6. myclip = attachMovie("mc", "mc"+k, k);
  7. myclip._y = 100;
  8. myclip._x = 170+myclip._width*k;
  9. //myclip.myText.text = "Button "+k;
  10. clipArray.push(myclip);
  11. //countArray.push(k);
  12. posArray.push(myclip._x);
  13. myclip.onPress = dostuff;
  14. }
  15. function move() {
  16. var xdif = posArray[this.jvar]-this._x;
  17. this.xspeed += xdif/this._parent.acceleration;
  18. this.xspeed *= this._parent.friction;
  19. this._x += this.xspeed;
  20. this.checkDistance();
  21. }
  22. checkDistance = function () {
  23. if (Math.abs(posArray[this.jvar]-this._x)<1) {
  24. this._x = posArray[this.jvar];
  25. delete this.onEnterFrame;
  26. }
  27. };
  28. function dostuff() {
  29. for (var i = 0; i<clipArray.length; i++) {
  30. // setting indexes
  31. clipArray[i].ivar = i;;
  32. }
  33. // deleting the mc the user clicked
  34. k = clipArray.splice(this.ivar, 1);
  35. // the mc you click is on the front
  36. clipArray = k.concat(clipArray);
  37. for (var j = 0; j<posArray.length; j++) {
  38. // re setting the indexes
  39. clipArray[j].jvar = j;
  40. trace(clipArray[j]+" "+clipArray[j].jvar);
  41. // calls move
  42. clipArray[j].onEnterFrame = move;
  43. }
  44. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Hmmm...

When you click on the 5 you want to have 5 1 2 3 4 ?

And what when you click on 4? Is it "4 1 2 3 5" or "4 5 1 2 3"?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.