1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| import mx.transitions.Tween;
import mx.transitions.easing.*;
var intervalId:Number;
var i:Number = 1;
var duration:Number = 10;
var xx:Array = new Array();
var yy:Array = new Array();
for (j = 0 ; j < 10 ; j++){
xx[j] = random(400);
yy[j] = random(300);
}
mc._x = xx[1];
mc._y = yy[1];
function executeCallback(p1:Number,p2:Number,p3:Number,p4:Number) {
duration = 2000;
var tweenx:Tween = new Tween(mc, "_x", Regular.easeInOut, p1, p2, 2, true);
var tweeny:Tween = new Tween(mc, "_y", Regular.easeInOut, p3, p4, 2, true);
clearInterval(intervalId);
if(i < 9) {
i++;
intervalId = setInterval(this, "executeCallback", duration, xx[i], xx[i+1], yy[i], yy[i+1]);
}
}
bouton.onRelease = function () {
if(intervalId != null) {
clearInterval(intervalId);
}
intervalId = setInterval(_root, "executeCallback", duration, xx[i], xx[i+1], yy[i], yy[i+1]);
} |
Partager