Flash教程:纯AS代码制作的燃烧的火焰效果 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

   

    背景

    var mcs:MovieClip = createEmptyMovieClip("query", -1);

    with (mcs) {

    beginFill(0x000000,100);

    lineStyle(0,0x000000,0);

    moveTo(0,0);

    lineTo(Stage.width,0);

    lineTo(Stage.width,Stage.height);

    lineTo(0,Stage.height);

    lineTo(0,0);

    endFill();

    }

    制作影片剪辑实例

    import flash.geom.*;

    var McR:Number = 40;

    var McA:Number = 60;

    var CreaMovie:MovieClip = this.createEmptyMovieClip("CreaMc", 0);

    with (CreaMovie) {

    fillType = "radial";

    colors = [0xFFFF00, 0xFFFF00];

    alphas = [McA, 0];

    ratios = [0, 0xFF];

    matrix = new Matrix();

    matrix.createGradientBox(McR,McR,0,0,0);

    beginGradientFill(fillType,colors,alphas,ratios,matrix);

    moveTo(0,0);

    lineTo(0,McR);

    lineTo(McR,McR);

    lineTo(McR,0);

    lineTo(0,0);

    endFill();

    }

    CreaMovie._visible = false;

    火效果

    var McNum:Number = 1;

    var McMore:Number = 200;

    var McRandom:Number = 6;

    var McY:Number = 4;

    var Mc_x:Number = Stage.width/2;

    var Mc_y:Number = Stage.height/2+Stage.height/4;

    var Mc_more:Number = 100;

    var Mc_scal:Number = 50;

    flame = function(){;

    var scale:Number=random(Mc_scal)+1;

    var flames:MovieClip=CreaMovie.duplicateMovieClip("flames"+McNum,McNum,{_x:Mc_x,_y:Mc_y,_alpha:Mc_more/2,_xscale:scale,_yscale:scale});

    flames.blendMode = "add";

    flames.fast=Math.floor(scale/10);

    flames.action=(random(2)==1)?1:-1;

    flames.scal=10-flames.fast;

    flames.n=flames.s=1;

    flames._r = flames._g = 255;

    flames._b =0;

    flames.gs=(10-flames.scal+2)*3;

    flames.onEnterFrame=function(){

    this._x+=this.fast*this.action*this.n*this.s;

    this._y-=McY;

    this._xscale+=this.scal*this.n*this.s;

    this._yscale+=this.scal*this.n*this.s;

    this._alpha+=10*this.n*this.s;

    this._g-=this.gs;

    if(this._g<=0){

    this._g=0;

    }

    new Color(this).setRGB(this._r << 16 | this._g << 8 | this._b);

    if(this._xscale>=Mc_more){;

    this.n=-1;

    this.s=0.2;

    };

    if(this._alpha>=Mc_more){;

    this._alpha=Mc_more;

    }else if(this._alpha<=random(20)){;

    this.removeMovieClip();

    delete this.onEnterFrame();

    };

    };

    if(McNum>=McMore){;

    McNum=0;

    };

    McNum++;

    };

    setInterval(flame,10);

最新文章