Hey, I have a question. This project I am working on needs a top view on a snowstorm. I was thinking I can use code similar to a starfield coming at you, and then modifying it so that the objects start from around you and fall towards the center. (opposite direction). However, when I change the code the way I believe I need to, I get the right thing to happen but not to regenerate. It happens only once, and once they reach the center, they don’t recreate around the edges of the screen. Here is the code I am using from a simple starfield tutorial:
_global.ppDist = 700;
_global.speed = 50;
//update function to handle perspective projection and scaling
update = function ()
{
perspective = ppDist / (ppDist - this.z);
this._x = this.x * perspective;
this._y = this.y * perspective;
this._xscale = this._yscale = 70 * perspective;
// add z motion…
this.z += speed;
// push back when it reaches the view position
if (this.z > 490)
{
this.z -= 2000;
}
}
//empty clips for drawing
_root.createEmptyMovieClip (“drawing”, 1);
_root.drawing.createEmptyMovieClip (“sq”, 1);
// centre the ‘drawing’ mc on the stage
_root.drawing._x = 300;
_root.drawing._y = 150;
// draws a solid white 2x2 square in the ‘sq’ mc
_root.drawing.sq.beginFill (0xffffff, 100);
_root.drawing.sq.moveTo (-1, -1);
_root.drawing.sq.lineTo (1, -1);
_root.drawing.sq.lineTo (1, 1);
_root.drawing.sq.lineTo (-1, 1);
_root.drawing.sq.lineTo (-1, -1);
_root.drawing.sq.endFill ();
// hide the original ‘sq’ off stage
_root.drawing.sq._y = 1000;
// make 198 copies of the square
for (i = 2; i < 200; i++)
{
initOb = {x:random (600) - 300, y:random (300) - 150, z:random (2000) - 1600};
//note: random(600)-300 gives a random integer between -300 & 299
//note: random(2000)-1600 gives a random integer between -1200 & 399
_root.drawing.sq.duplicateMovieClip (“s” + i, i, initOb);
_root.drawing[“s” + i].onEnterFrame = _root.update;
}
I have been playing around with the Z positioning lines in the middle. Any ideas?? I would really appreciate help. Thanks in advance!!!
Luke