今天是:

注册会员|会员登陆|设为首页|加入收藏|广告服务|韩文翻译|RSS阅读|繁體中文

您现在的位置: 韩国设计资源网 >> 设计师学院 >> 网页设计 >> Flash >> 教程正文

Flash8 Blendmode——光影变换

  • 作者:egoldy 文章来源:webstudio 点击数: 更新时间:2007-1-22 22:15:44 用户收藏
 this.xtempo; 
        this.ty += this.ytempo; 
        this._x = this.x0+Math.sin(this.tx)*this.xd; 
        this._y = this.y0+Math.cos(this.ty)*this.yd; 
    }; 
     
}

斜体加粗的代码是我们所修改的位置,我们增加了粒子的数量,同时加入了_xscale._yscale.缩放的随机值,这样便会放大粒子增加粒子的重合度。效果如下:

Flash8


接下来我们在这段代码的基础上在次进行修改。我们此次要变换一下融合模式,就会得到不同的效果。如下代码。
//定义中心位置 
var cx = 0; 
var cy = 0; 
//设定循环20次,准备从库中复制链接id为partical的影片. 
for (var i = 0; i<100; i++) { 
    //复制影片剪辑,引用名称为mc. 
    var mc = this.attachMovie("partical", "p"+i, i); 
    with (mc) { 
        //初始化影片剪辑的位置,注意此时cx,cy是用来调整mc实例的偏移位置的. 
        _x = cx+Math.random()*590; 
        _y = cy+Math.random()*350; 
        _xscale = _yscale = 140 * Math.random()*5+1; 
    

    //针对mc应用融合模式类型"add" 
    mc.blendMode = "hardlight"; 
    mc.cacheAsBitmap = true;
 
    //设定mc实例的角度随机值 
    mc.tx = random(360); 
    mc.ty = random(360); 
    //设定用于mc角度的增量随机值 
    mc.xtempo = Math.random()/10; 
    mc.ytempo = Math.random()/10; 
    //设定mc实例的速度随机值 
    mc.xd = Math.random()*10+1; 
    mc.yd = Math.random()*10+1; 
    mc.x0 = mc._x; 
    mc.y0 = mc._y; 
    //跳转到指定的帧,以变换不同颜色的小球上. 
    mc.gotoAndStop(random(5)+1); 
    //通过onEnterFrame循环,来让粒子移动. 
    mc.onEnterFrame = function() { 
        this.tx += this.xtempo; 
        this.ty += this.ytempo; 
        this._x = this.x0+Math.sin(this.tx)*this.xd; 
        this._y = this.y0+Math.cos(this.ty)*this.yd; 
    }; 
     
}


斜体加粗的代码为我们所修改过的位置,我们增大了缩放,同时将融合模式换成了hardlight.当然你可以试一下其它的融合方式,同时我们增加了mc.cacheAsBitmap = true.通过这一句是加速我们的影片剪辑的运算速度。测试的效果如下。

上一页  [1] [2] [3]