文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | firefox | WPS | 杀毒软件 | Picasa
清风网络
首 页 软件下载 网络学院 数码学院
QQ 电脑入门 游戏 操作系统 图形图像 办公软件 媒体动画 精文荟萃 常用软件 网页编程 技术开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络学院媒体动画FlashFlash AS动画实例:风吹云飘草动
精品推荐
特别推荐
·由浅入深学习Flash制作高射炮游戏
·由浅入深学习Flash制作高射炮游戏(续)
·遮照及文字遮照的几个概念和事例
·创建一个实用Flash站点的十大技巧
·Flash动画制作实例:小野人玩摇滚
·Flash技术在电子杂志设计制作应用
·用js+flash实现网页中复制数据功能
·教你如何去掉网页上的Flash动画虚线框
·让Flash动画适应任何分辨率的网页
·基础:flash9.ocx 加载错误解决方法
·Flash AS基础精典教程
·Flash AS教程之四 动态文本的编写以及外部文本的载入
·flash载入外部文本设置颜色的问题
·Flash制作漂亮的三重卷动相册特效动画
·关于网页中Flash弹出网页窗口的详细讲解
·用FLASH遮罩效果做图片切换效果
·实例技巧:Flash与HTML实现交互的实例
·Macromedia Flex 教程: Flex入门教程
·高级游戏制作:Flash制作物体弹跳电脑游戏
·技巧:用Flash制作动画的经典问题问答
热点TOP10
·FLASH制作一个可以伸缩的导航条
·flash声音特效实例--架子鼓(图)
·由浅入深学习Flash制作高射炮游戏
·Flash动画制作实例:小野人玩摇滚
·Flash 图片轮换效果
·高级游戏制作:Flash制作物体弹跳电脑游戏
·用FLASH遮罩效果做图片切换效果
·将数码照片做成自动放映的Flash
·用Flash MX模板制作幻灯片效果
·Flash教程:制作随机画圆弧动画
·轻松做出精美3D效果 浅析Flash 3D动画制作
·Flash遮罩特效实例--放大镜(图)
·Photoshop 7.0制作一杯热茶
·Macromedia Flex 教程: Flex入门教程
·Flash联合粒子特效软件打造超酷浪漫动画特效
·Flash AS3:动态文本滚动条
·Flash制作漂亮的三重卷动相册特效动画
·精彩推荐:全Flash网站制作实例
·Flash8 字体特效
·Flash AS基础精典教程

Flash AS动画实例:风吹云飘草动

日期:2007年10月29日 作者: 查看:[大字体 中字体 小字体]


  我们可以直接用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; 
}

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

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 实现好看的清晰的飘动云和风吹草动画

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

(出处:清风下载学院






上一篇:Excel函数与数据有效性配合快速填通知书

下一篇:网页制作之用Dreamweaver优化网页

Flash AS动画实例:风吹云飘草动 相关文章:
·ASP.NET上传文件的实例
·Photoshop实例:制作超酷影片画面场景
·Photoshop实例:调出漂亮MM的唯美效果
·DIV CSS网页布局实例:十步学会用CSS建站
·菜鸟学习javascript实例教程
·综合实例:PS洗衣粉包装设计印刷全攻略
·ADSL共享方案及实例操作
·flash声音特效实例--架子鼓(图)
·常见网络故障诊断实例70
·PS初学者实例教程——修图的常用方法与技巧三
Flash AS动画实例:风吹云飘草动 相关软件:
·中文版Excel 2003实例与技巧
·AutoCAD 2004基础与实例教程
·CorelDraw12 入门与实例(图文教程 菜鸟先飞系列教材)
·中文版 AutoCAD2004 应用实例与技巧
·Flash MX 动画制作实例教程
·Visio 2003概览与实例
·注册表实例应用视频教程swf
·PhotoShop7 设计百例 + 经典实例教程 + 滤镜教学
·Photoshop视频实例教程系列电子书 V1.0
·AutoCAD2002入门与实例详解

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.viphot.com
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.viphot.com All Rights Reserved. 鄂ICP备05000083号Powered by:vipcn