用Flash脚本做移动星空怎么做?
明亮的星空在天幕上缓缓地移动,再加上一些星星的闪烁,这 景色很是迷人。 我看到许多动画和广告,也都用星空作为背景。表现方法也各 不相同。不知是怎样做的?最好能用Flash 脚本做出来。 问:用Flash 脚本做移动星空怎么做? 答:做移动星空一般用2 种方法:一种是利用原有星空图使之移 动,这样可以做得比较详细,适合专业使用,但文件较大;一种是 自动生成星空并使它移动,文件较小,适合一般使用。 分述如下: 1.利用原有星空图,使它移动。 用一幅星空图做成影片剪辑(MC),再做成移动动画。 1、怎样选取星空图。 从星空光盘中选取合适的图片,或打开星空图软件,再用抓 图软件把合适的图片抓下来。文后附的那张图片,就是用SnagIt 抓图软件,从星空图软件中抓下来的,(颖易立体星图 2.5 免费 版 490 KB www.yingyi.net),观测时间和位置都可以设置,因 而可以做得比较详细具体。 2、将星空做成动画。 在 Flash 中,新建一个影片剪辑pic1,将星空图片拉入, 并排复制一份,做成一个影片剪辑。 在主场景中,将影片剪辑拉到前台,再加上脚本层。影片剪辑 实例名称填为 pic1 。保存、发布即可。 详细步骤请参阅: 《Flash 一张图片不断循环怎样制作》 详见: wy02021.htm 2.Flash 脚本自动生成星空并使它移动。 找一个适用的Flash 脚本。 利用FlashMX实例脚本,加以改编,可以较好的实现要求的效果。 改编步骤如下: 1.修改平台。 修改|文档 原尺寸: 466X277 改为 540X400 背景色: 原灰色改为白色。 帧频: 30 fps 不变。 2.删除"frame"层。 3."buttons & faders"层的处理。 分别点击各个按钮。按右键,用剪切删去多余的按钮。 只留一个按钮(生成十字星的那个),并拉到图片的左下角。 62.3 X 62.3 X:0 Y:354 4."background"层的处理。 清除原有设置。 编辑|全选|清除 将属性改为"被遮罩"。 右击"background",选"属性",选取 "被遮罩"。 用画方块工具,前景选青色,背景选深蓝色。 宽:536 X:2 高:394 Y:2 5."mask"层的处理。 宽:536 X:2 高:394 Y:2 6."star field"层的处理。 宽:740 X:-200 高:600 Y:-200 7、"action"层的处理。 修改脚本。 原脚本(修改前的脚本): // initialize variables and properties starField.star._visible = 0; initx = starField._x; inity = starField._y; //按钮和刻度设定,决定星空移动的快慢和方向。 _root.onEnterFrame = function() { with (starfield) { // move starfield based on the positions of the faders _x += (horizfader._x-horizfader.initx)/15; _y += (vertfader._y-vertfader.inity)/15; // // loop the starfield if (_x>initx+220) { _x = initx; } if (_x<initx) { _x = initx+220; } if (_y>inity+215) { _y = inity; } if (_y<inity) { _y = inity+215; } } }; // 按下按钮,星空开始生成及移动。 // generate star field when generate button is clicked generate.onRelease = function() { for (i=1; i<=300; i += 4) { for (a=0; a<=3; a++) { duplicateMovieClip(starfield.star, "star"+(i+a), i+a); if (i%7 == 0) { starfield["star"+(i+a)]._xscale = 200; starfield["star"+(i+a)]._yscale = 200; } } starfield["star"+i]._x = Math.floor(Math.random()*220); starfield["star"+i]._y = Math.floor(Math.random()*215); starfield["star"+(i+1)]._x = starfield["star"+i]._x-220; starfield["star"+(i+1)]._y = starfield["star"+i]._y; starfield["star"+(i+2)]._x = starfield["star"+i]._x-220; starfield["star"+(i+2)]._y = starfield["star"+i]._y-215; starfield["star"+(i+3)]._x = starfield["star"+i]._x; starfield["star"+(i+3)]._y = starfield["star"+i]._y-215; } }; // // toggle dotted cross hair visibility toggle.onRelease = function() { starfield.centerlines._visible = !starfield.centerlines._visible; }; 修改后的脚本: // initialize variables and properties starField.star._visible = 1; // 此处由 "0" 改为 "1" initx = starField._x; inity = starField._y; // _root.onEnterFrame = function() { with (starfield) { // 改变坐标的增幅值,可调整星空移动的快慢和方向。 // 此处原为由按钮刻度设定,改为具体数值,即星空向西偏北方向移动。 _x += -4/15; _y += -1/15; // loop the starfield if (_x>initx+220) { _x = initx; } if (_x<initx) { _x = initx+220; } if (_y>inity+215) { _y = inity; } if (_y<inity) { _y = inity+215; } } }; // 改为不需按下按钮,星空就自动生成并开始移动。 // 位置作了一些调整。 // generate star field when generate button is clicked for (i=1; i<=300; i += 4) { for (a=0; a<=3; a++) { duplicateMovieClip(starfield.star, "star"+(i+a), i+a); if (i%7 == 0) { starfield["star"+(i+a)]._xscale = 200; starfield["star"+(i+a)]._yscale = 200; } } starfield["star"+i]._x = Math.floor(Math.random()*220); starfield["star"+i]._y = Math.floor(Math.random()*215); starfield["star"+(i+1)]._x = starfield["star"+i]._x-220; starfield["star"+(i+1)]._y = starfield["star"+i]._y; starfield["star"+(i+2)]._x = starfield["star"+i]._x-220; starfield["star"+(i+2)]._y = starfield["star"+i]._y-215; starfield["star"+(i+3)]._x = starfield["star"+i]._x; starfield["star"+(i+3)]._y = starfield["star"+i]._y-215; } // // toggle dotted cross hair visibility toggle.onRelease = function() { starfield.centerlines._visible = !starfield.centerlines._visible; }; 星空图片 snap.jpg 夏夜星空:设定为 2004年7月5日22时 北京星空图片 40 KB 移动星空动画 0301.swf 图上的星座标注的字看不清怎么办?下载后,全屏播放就可以看 清楚。 0301.swf 40 KB 原动画 star.swf 按键启动生成星空,刻度改变快慢和方向。 star.swf 9 KB 修改后的动画 star1.swf 按键可以 显示/隐藏 十字线。 star1.swf 6 KB 下载: 源程序下载 wy04071.zip 210 KB 河石 /编 2004.6.25 相关链接: 《怎样用好Photoshop的渐变技巧?》 《Flash 特效脚本实例怎样应用?》 黄河之滨 网站 : http://hhstone.vip.sina.com : http://www.hhstone.com