我正在使用as2。如何在某个帧上删除这些雪花?我正在使用第40帧的阵列创建雪花。我想摆脱60左右的帧。
var snowflake:Array;
for (var i:Number=0;i<100;i++) {
snowflake[i]=new Snowflake(this);
}
import Snowflake.*;
class Snowflake {
public var _snowflake:MovieClip;
private var _ranSnowflake:Number;
private var i:Number;
private var k:Number;
private var rad:Number;
private static var NUM_SNOWFLAKE_TYPES:Number=7;
private static var MOVIE_WIDTH:Number=590;
private static var MOVIE_HEIGHT:Number=390;
private static var FALLING_SPEED:Number=30;
private static var WIND_SPEED:Number=5;
private static var ROTATION_SPEED:Number=4;
function Snowflake(container:MovieClip) {
this._ranSnowflake=Math.round((Math.random()*Snowflake.NUM_SNOWFLAKE_TYPES)+1);
this._snowflake=container.attachMovie("snowflake"+this._ranSnowflake,"snowflake",container.getNextHighestDepth());
this._snowflake._x=(Math.random()*Snowflake.MOVIE_WIDTH);
this._snowflake._y=0;
this._snowflake.parent=this;
this.i=1+Math.random()*2;
this.k=-Math.PI+Math.random()*Math.PI;
this.rad=0;
//giving each snowflake unique characteristics
this._snowflake._xscale = this._snowflake._yscale=Math.random()*30;
this._snowflake._alpha = 75+Math.random()*100;
this._snowflake.onEnterFrame=function() {this.parent.snowflakeEnterFrame(this._snowflake);}
trace("SNOWFLAKE X:"+this._snowflake._x+" Y:"+this._snowflake._y);
trace(this._currentframe);
}
public function snowflakeEnterFrame() {
//putting it all together
this.rad += (k/180)*Math.PI;
this._snowflake._x -= Math.cos(rad);
this._snowflake._y += i;
if (this._snowflake._y>=Snowflake.MOVIE_HEIGHT) {
this._snowflake._y = -Snowflake.FALLING_SPEED;
}
if ((this._snowflake._x>=Snowflake.MOVIE_WIDTH) || (this._snowflake._x<=0)) {
this._snowflake._x = -Snowflake.WIND_SPEED+Math.random()*Snowflake.MOVIE_WIDTH;
this._snowflake._y = -Snowflake.WIND_SPEED;
}
this._snowflake._rotation+=Snowflake.ROTATION_SPEED;
}
public function vis(){
this._snowflake.visible = false;
}
}
答案 0 :(得分:0)
这样的东西(适用于任何框架):
for(var i:Number = 0; i<snowflake.length; i++){
this.removeMovieClip(snowflake[i]._snowflake);
}
遍历所有雪花并将其从容器中移除。