你可以看一下你的代码;type并没有起到限制作用,可以在加一个判断,代码如下:
stop();
var min_y = 50;
var depth:Number = 1;
var speed:Number = 1;
var type:Number;
_root.onEnterFrame = function() {
if(ran(0,10)==5){
type = ran(1,4);
//type=random(50);
trace(type);
var mc:MovieClip = this.attachMovie("a"+type, "a"+depth, depth);
if (type == 1) {
mc._x = 200;
mc._y = 500;
}
if (type == 2) {
mc._x = 0;
mc._y = 500;
}
if (type == 3) {
mc._x = 460;
mc._y = 500;
}
if (type == 4) {
mc._x = 330;
mc._y = 500;
}
mc.onEnterFrame = function() {
mc._y -= speed;
if (mc._y<min_y) {
this.removeMovieClip();
}
};
depth++;
if(depth>100){
depth=1;
}
}
};
function ran(minnum:Number,maxnum:Number):Number{
return(random(maxnum-minnum+1)+minnum);
}