Step-1: Create a small Star and convert it movie clip – and Drag and Drop Movie Clip in Screen Window.
Step-2: Create a new Layer and increase blank key frame three Steps
Step-3: In the first layer, insert the actions

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);

Step-4: In the second key frame, insert this action:

for (i=0;i300) { 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 )
}

Step-5: Finally, in the third, insert

gotoAndPlay (2);

To see the effect click on the link:-
http://blog.codez.in/post-files/starfield.swf

Latest posts by Dipak Saha

  • Share/Bookmark