Frame 1
function Star() {
this.x = 0;
this.y = 0;
this.z = 0;
this.mc = null;
this.reset();
this.reset = function () {
this.x = ((Math.random() * APP_WIDTH) - (APP_WIDTH * 0.5)) * STAR_DIST_MAX;
this.y = ((Math.random() * APP_HEIGHT) - (APP_HEIGHT * 0.5)) * STAR_DIST_MAX;
this.z = STAR_DIST_MAX;
};
this.paint = function () {
if (this.mc != null) {
this.mc._x = this.x / this.z;
this.mc._y = this.y / this.z;
this.mc._xscale = 100 / this.z;
this.mc._yscale = 100 / this.z;
}
};
}
function update(dt) {
var _local3 = dt * 0.001;
var _local4 = g_stars.length;
var _local1;
var _local2 = 0;
while (_local2 < _local4) {
_local1 = g_stars[_local2];
_local1.z = _local1.z - (_local3 * g_camVel);
if (_local1.z < 0.1) {
_local1.reset();
}
_local2++;
}
return(0);
}
function paint() {
var _local3 = g_stars.length;
var _local1;
var _local2 = 0;
while (_local2 < _local3) {
_local1 = g_stars[_local2];
_local1.paint();
if ((((_local1.mc._x < -200) || (_local1.mc._x > 200)) || (_local1.mc._y < -200)) || (_local1.mc._y > 200)) {
_local1.reset();
_local1.paint();
}
_local2++;
}
return(0);
}
function doFrame() {
var _local2 = getTimer();
var _local1 = _local2 - g_prevT;
if (_local1 > 0) {
update(_local1);
paint();
}
g_prevT = _local2;
return(0);
}
function initialize(mcDst) {
var _local1;
var _local2;
_local1 = 0;
while (_local1 < g_stars.length()) {
if (_local2.mc != null) {
_local2.mc.removeMovieClip();
}
_local1--;
}
g_stars = new Array();
_local1 = 0;
while (_local1 < NUM_STARS) {
_local2 = new Star();
var _local3 = "star" + String(_local1);
mcDst.attachMovie("Star", _local3, 100 + _local1);
_local2.mc = mcDst[_local3];
_local2.paint();
g_stars.push(_local2);
_local1++;
}
g_prevT = getTimer();
return(0);
}
var STAR_DIST_MAX = 10;
var STAR_DIST_MIN = 0.1;
var NUM_STARS = 100;
var CAM_VEL_DEFAULT = 4;
var APP_WIDTH = 400;
var APP_HEIGHT = 400;
var g_stars = new Array();
var g_prevT = 0;
var g_camVel = CAM_VEL_DEFAULT;