一个随机运动的代码

      flash学习 2004-10-29 22:9
this._x = (this._y=200);
for (var i = 0; i<30; i++) {
    mcp = this.createEmptyMovieClip("mc"+i, i);
    //每个mc中定义一个方法
    this["mc"+i].newHeading = function() {
        this._x = 200-random(400);
        this._y = 50-random(100);
        this._alpha = 50+random(50);
        this.xv = ((.5-Math.random())*5)%5;
        this.yv = ((.5-Math.random())*5)%5;
        this.av = ((.5-Math.random())*5);
    };
    this["mc"+i].newHeading();
    this["mc"+i].onEnterFrame = function() {
        (this._x<=-200 || this._x>=200) ? (this.xv=-this.xv) : (this.xv+Math.random()*5);
        this._x += this.xv;
        (this._y<=-50 || this._y>=50) ? (this.yv=-this.yv) : (this.yv+Math.random()*5);
        this._y += this.yv;
    };
    this["mc"+i].c = random(40)+5;
    for (var j = 5; j>0; j--) {
        this["mc"+i].lineStyle(j*4, 0x005544, 20-j*2);
        this["mc"+i].lineTo(j%5, 0);
    }
}
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}