»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
Creating a Realistic Star field effect in Flash Creating a Realistic Star field effect in Flash
1.Create a small star of your choice.
2.Give it an instance name of "star".
3.In the first frame give this actions:
numstars = 90;
speed = 6;
star_field = new Array (numstars);
//x is x axis, y is y axis, z is speed of star
function star(x,y,speed)
{
this.x = x;
this.y = y;
this.speed = speed;
}
for (i=0;i {
star_field[i] = new star(random(400),random(200),random(speed)+1);
duplicateMovieClip ("star", "star_" add i, i+10);
}
function movestars()
{
for (i=0;i {
star_field[i].x+= star_field[i].speed;
if (star_field[i].x>400) { 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 )
}
}
setInterval(movestars,10);
|
|