利用数组帮助实现循环滚动(as2.0)
var mc_width = 200;
var mc_height = 100;
var mcNum = 10;
var move_v = 0;
var prev_v = 0;
var stageHeight = Stage.height;
var mc_array = [];
for (var i = 0; i<mcNum; i++) {
mc_array[i] = newMC(10, i*mc_height, mc_width, mc_height, i+1);
}
onEnterFrame = function () {
move_v = (move_v+(_ymouse-stageHeight/2)/10+mc_height)%mc_height;
var v = move_v-prev_v;
if (Math.abs(v)>mc_height/2) {
v<0 ? mc_array.push(mc_array.shift()) : mc_array.unshift(mc_array.pop());
}
prev_v = move_v;
mc_array[0]._y = -move_v;
for (var i = 1; i<mcNum; i++) {
mc_array[i]._y = mc_array[i-1]._y+mc_height;
}
};
function newMC(x, y, width, height, text) {
var c = _root.getNextHighestDepth();
var mc:MovieClip = _root.createEmptyMovieClip("mc"+c, c);
mc._x = x;
mc._y = y;
var txt:TextField = mc.createTextField("txt", 0, 0, height/2-30, width, 60);
txt.text = text;
txt.selectable = false;
var format:TextFormat = new TextFormat();
format.align = "center";
format.size = 40;
format.font = "Arial Black";
txt.setTextFormat(format);
mc.lineStyle(1, 0);
mc.moveTo(0, 0);
mc.lineTo(width, 0);
mc.lineTo(width, height);
mc.lineTo(0, height);
mc.lineTo(0, 0);
mc.endFill();
return mc;
}