/*/
* 标题: 填充类
* 描述: 使用链接自库中的元件填充指定的MC
* 版权: (c) 2005 hjc Copyright
* 作者: hjc
* 版本: 1.0
* 时间: 2005.05.13
/*/
class Fill {
//将要填充的MC
private var mc:MovieClip;
//库中链接的标识符
private var link:String;
//用于确定是否将填充层作为背景,即深度最低
private var bottom:Boolean;
//填充层的深度
private var depth:Number;
//可选参数,指定填充范围的宽
private var width:Number;
//可选参数,指定填充范围的高
private var height:Number;
//临时变量,用于确定循环中MC的深度
private var n:Number = 0;
//----------------------------------------
//----------构造函数----------
function Fill(my_mc:MovieClip, my_link:String, my_bottom:Boolean, my_width:Number, my_height:Number) {
mc = my_mc;
link = my_link;
//----------------------------------------
//----------是否为背景填充----------
if (my_bottom) {
depth = -16384;
} else {
depth = mc.getNextHighestDepth();
}
//----------------------------------------
//----------重载:宽----------
if (typeof (my_width) != "number") {
width = mc._width;
} else {
width = my_width;
}
//----------------------------------------
//----------重载:高----------
if (typeof (my_height) != "number") {
height = mc._height;
} else {
height = my_height;
}
//----------------------------------------
//----------创建填充层----------
mc.createEmptyMovieClip("tmp", depth);
//----------------------------------------
//----------排列----------
for (var i = 0; i<Math.ceil(height/mc.tmp.mc1._height); i++) {
for (var j = 0; j<Math.ceil(width/mc.tmp.mc1._width); j++) {
mc.tmp.attachMovie(link, "mc"+(n+1), n+1);
eval(mc+".tmp.mc"+(n+1))._x = mc.tmp.mc1._width*j;
eval(mc+".tmp.mc"+(n+1))._y = mc.tmp.mc1._height*i;
n++;
}
}
}
}