flash 调用 脚本
Creating a starfield effect is easy! To begin, download the sample files here.
创建星空效果很容易! 首先,请在此处下载示例文件 。
1. Create a small star shape, and convert it to a movie clip. Give it an instance name of star.
1.创建一个小的星形,然后将其转换为影片剪辑。 给它指定一个star的实例名称。
2. Extend the existing layer by three frames. Then, create a new layer above the existing layer, and create three blank frames in this layer.
2.将现有层扩展三个框架。 然后,在现有层之上创建一个新层,并在该层中创建三个空白框架。
3. In the first layer, insert the actions:
3.在第一层中,插入操作:
numstars = 100; speed = 5; star_field = new Array (numstars); //x is x axis, y is y axis, speed is speed of star function star(x,y,z) { this.x = x; this.y = y; this.speed = speed; } for (i=0;i<numstars;i++) { star_field[i] = new star(random(300),random(200),random(speed)+1); duplicateMovieClip ("star", "star_" add i, i+10); }4. In the second key frame, insert this action:
4.在第二个关键帧中,插入以下操作:
for (i=0;i<numstars;i++) { star_field[i].x+= star_field[i].speed; if (star_field[i].x>300) { star_field[i].x = 0; } setProperty ("star_" add i , _x , star_field[i].x ) setProperty ("star_" add i , _y , star_field[i].y ) setProperty ("star_" add i , _alpha , star_field[i].speed*40 ) }5. Finally, in the third, insert:
5.最后,在第三行中插入:
gotoAndPlay (2);That’s it! Test the movie!
而已! 测试电影!
翻译自: https://www.sitepoint.com/script-star-field-effect/
flash 调用 脚本
相关资源:满天星空flash文件