ddc
联网
平面设计 画册 VI欣赏 包装 CG-插画 搜索 个人网页 Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校 专题欣赏 SEO 图标欣赏 专题
上海网站建设 网站建设 域名注册 虚拟主机 广州网站设计 域名注册 广州网站建设 上海网站建设 虚拟主机 广州网页设计 虚拟主机 域名注册 acg ACG玩家 品牌设计
求创科技
网站建设
中国互联
投稿
素材出售
中国设计秀
中资源
当前位置:网络学院首页 >> 设计教程 >> Flash >> Flash AS制作风吹云飘草动动画

Flash AS制作风吹云飘草动动画 (1)

来源:中国设计秀    作者:    点击:785     加入收藏    发表评论
0
顶一下
  我们可以直接用Flash的ASAS代码生成风吹云飘,风吹着青草左右摇摆的动画。因为AS的运算会拖慢机器,所以这里就不提供效果演示了,给大家截个图。

Flash AS 实现好看的清晰的飘动云和风吹草动画

  制作方法如下。

  首先建立两个空的影片剪辑cloud和grass。

  先建立云的影片剪辑(里面什么都不画)

Flash AS 实现好看清晰的飘动云和风吹草动画

  选择该元件的第一帧,添加如下代码。

//Number of clouds
clouds=6;
//These are just general boundaries.
//To use exact boundaries, create a mask in the parent level of the size desired
//Height of the sky
skyheight=Stage.height;
//Width of the sky
skywidth=Stage.width;
//Max size of a cloud
cloudsize=300;
//Amount of blur applied to the shapes to make them cloud-like
blursize=40;
//Clouds move at a random speed. this is the minimum speed
cloudminspeed=.5;
//Variance in speed from cloud to cloud
cloudspeedvariance=1;
//Create the clouds
for(c=1;c<=clouds;c++){
//create an empty movie clip to hold the cloud
 this.createEmptyMovieClip("cloud"+c,this.getNextHighestDepth());
//generate a cloud. Pass in the instance name of the newly created cloud
 shapecloud("cloud"+c);
//Set the x position to a random position within the boundaries
 eval("cloud"+c)._x=Math.random()*skywidth-eval("cloud"+c)._x/2;
//Set the y position to a random position within the boundaries
 eval("cloud"+c)._y=Math.random()*(skyheight)-eval("cloud"+c)._height;
}
//Run at the start of each frame
onEnterFrame=function(){
//Run for each cloud
 for(c=1;c<=clouds;c++){
//Move the cloud to the left according to its speed
  eval("cloud"+c)._x-=eval("cloud"+c).cloudspeed;
//If the cloud is past the stage to the left, reset it to the right. Create a new shape and color  
  if(eval("cloud"+c)._x+(eval("cloud"+c)._width/2)+cloudsize<0){
//Reset the x position
   eval("cloud"+c)._x=skywidth;
//Reshape and recolor the cloud
   shapecloud("cloud"+c);
  }
 }
}
//This function creates the shape and color of a cloud
function shapecloud(cloudid){
//Clear the current contents of the cloud
 eval(cloudid).clear();
//Set the new shade between 224 and 255. This number is used for the red, green, and blue, to create a grayscale color
 cloudcolor=Math.round(Math.random()*31)+224;
//Use no line
 eval(cloudid).lineStyle(undefined, (cloudcolor+cloudcolor*0x100+cloudcolor*0x10000), 100, false, "none", "none", "none", 1);
//Set the fill color. cloudcolor is used 3 times, for red, green, and blue
 eval(cloudid).beginFill((cloudcolor+cloudcolor*0x100+cloudcolor*0x10000));
//Set a starting coordinate for the cloud 
 eval(cloudid).moveTo(Math.random()*cloudsize,Math.random()*cloudsize);
//Draw an invisible line to another point the combined lines form shapes, which are the clouds.
//They don't look much like clouds until the blur is applied
 eval(cloudid).lineTo(Math.random()*cloudsize,Math.random()*cloudsize);
 eval(cloudid).lineTo(Math.random()*cloudsize,Math.random()*cloudsize);
 eval(cloudid).lineTo(Math.random()*cloudsize,Math.random()*cloudsize);
 eval(cloudid).lineTo(Math.random()*cloudsize,Math.random()*cloudsize);
 eval(cloudid).lineTo(Math.random()*cloudsize,Math.random()*cloudsize);
//Apply a blur to the shape
 eval(cloudid).filters = [new flash.filters.BlurFilter(blursize,blursize,2)];
//Set a new cloud speed
 eval(cloudid).cloudspeed=Math.random()*cloudspeedvariance+cloudminspeed; 
}

  同样办法再新建立一个草的影片剪辑

[1] [2]
2007-10-26 09:50:00    出处:
Google
热点文章/相关文章

音乐
嫁衣 画心 放生 天亮了 牡丹江 那滋味 擦肩而过 怀念过去 北京欢迎你 突然好想你 吻的太逼真 说好的幸福呢 坐上火车去拉萨 没有人比我更爱你
愚爱 心碎 稻香 带我走 醉赤壁 魔杰座 我还想她 明天过后 一定要爱你 等爱的玫瑰 原谅我一次 越单纯越幸福 最后一次的温柔 给我一首歌的时间
白狐 光荣 降临 下雨天 小酒窝 樱花草 恋爱新手 说唱脸谱 红色高跟鞋 寂寞才说爱 深深爱过你 爱上你是个错 即使知道要见面 不是因为寂寞才想你
城府 假如 花海 兰亭序 棉花糖 舍不得 最后一次 女人如烟 外滩十八号 我们的纪念 我们的无奈 心在跳情在烧 爱上你是我的错 爱情里没有谁对谁错
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明 | 网站公告 | 友情链接 | 留言 | 旧版入口