首页  |  精品网站  |  原创作品秀   |  艺术设计  |  网络学院  |  信息中心  |  站内搜索  |  求职招聘  |  建站资源  |  服装网站  |  编程开发 |  设计论坛 
  平面设计 画册 VI欣赏 包装 CG-插画   酷站 个人网页 商业网站   Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校   专题欣赏 SEO 图标欣赏
域名注册 虚拟主机 广州网站建设 广州网页设计 IDC赞助 设计资源下载 虚拟主机 域名注册 品牌网站建设 服装品牌网站建设 广告服务 网站推广 娱乐
当前位置:首 页 >> 网络学院 >> Flash ※ FreeHand >> Flash AS制作风吹云飘草动动画

Flash AS制作风吹云飘草动动画


中资源
转载请注明出处-中国设计秀-cnwebshow.com

Flash AS 实现好看的清晰的飘动云和风吹草动画选择第一帧添加如下代码。

//Height of each blade of grass
grassheight=35;
//Average space in between each blade of grass
grassspacing=5;
//Maximum sway of each blade of grass
maxsway=20;
//Number of blades of grass along the x axis
xplots=30;
//Number of blades of grass along the y axis
yplots=20;
//The wind has an x position and the grass is attracted to the position
windxpos=0;
//Velocity of the wind left and right
windspeed=0;
//Gives the grass a bent effect. The grass bends 1/4 of the way up
grasscontrol=grassheight/4;
//Array containing the info for each blade of grass
grasscoords=[];
//These loops go through the field, planting each blade of grass
for (xpos=0; xpos<xplots; xpos++) {
 for (ypos=0; ypos<yplots; ypos++) {
  //x position, y position, sway, and color
  grasscoords.push([xpos*grassspacing+Math.random()*grassspacing,ypos*grassspacing+Math.random()*grassspacing,0,Math.round(Math.random()*128)*65536+Math.round(Math.random()*76+146)*256]);
 }
}
//Run on each frame
onEnterFrame=function(){
//Clear all of the grass so it can be redrawn with different sway
 this.clear();
//Change the speed of the wind
 windspeed=Math.max(-50,Math.min(50,windspeed+Math.random()*40-20));
//Move the position the blades are attracted according to the windxpos
 windxpos+=windspeed;
//If the windxpos moves too far to the left, reverse its speed
 if(windxpos<-100){
  windxpos=-100;
  windspeed*=-1;
 }
//If the windxpos moves too far to the right, reverse its speed
 else if(windxpos>grassspacing*xplots+100){
  windxpos=grassspacing*xplots+100;
  windspeed*=-1;
 }
//handle the redraw for each blade of grass
 for(coord=0;coord<grasscoords.length;coord++){
//Set the line style. 0 means use hairline width and grasscoords[coord][3] is the color   
  this.lineStyle(0, grasscoords[coord][3], 100, false, "normal", "none", "none", 1);
//Adjust the sway according to the grass's current sway and the windxpos
  grasscoords[coord][2]=Math.max(-maxsway,Math.min(maxsway,grasscoords[coord][2]+Math.max(-maxsway,Math.min(maxsway,(windxpos-grasscoords[coord][0])/100))))+(Math.random()*3-1.5);
//Move to the base of the blade of grass
  this.moveTo(grasscoords[coord][0],grasscoords[coord][1]);
//Draw a curved line to the new top of the blade of grass
  this.curveTo(grasscoords[coord][0],grasscoords[coord][1]-grasscontrol,grasscoords[coord][0]+grasscoords[coord][2],grasscoords[coord][1]-grassheight+Math.abs(grasscoords[coord][2]/2));
 }
}

  然后回到主场景中,建立两个图层,下面的为云的图层,上面的为草的图层,这里我绘制了一个放草的框框。

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

  按Ctrl+L打开库分别把草元件和云元件放到相应的图层。给草命名实例grass。

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

  最后可以测试影片了!但是好象机器运行速度在减慢啊!祝你好运!



<< 1 2 >>
转载请注明出处-中国设计秀-cnwebshow.com



投稿 】【对本文进行评论】 【字体: 】【发布于2007-10-26 09:50】
 认证LOGO下载
     
Copyright © 2005-2007 中国设计秀_网页设计教程_优秀网页设计欣赏_平面设计欣赏 All Right Reserved.
做最专业的设计服务网站,秀出自我,秀出精彩!中国设计秀,秀---无处不在!!
QQ:54292427  8208442 MSN:kingvisual#hotmail.com 交流群:9107036 3848215 8850631
粤ICP备05067046号 RSS