I’m trying to modify this script so that instead of using the onPress to trigger the duplicateMovieClip I can use the setInterval, here’s my script:
_global.globali=0;
particle = function () {
// PURPOSE: defines the particle object
//
// initialize properties
this.speedX = (Math.random()*8)-4;
this.speedY = (Math.random()*8)-4;
this.lowX = 0;
this.lowY = 0;
this.highX = 550;
this.highY = 400;
// END initialize properties
//
// Define events
this.onEnterFrame = function() {
if (this._x<this.lowX) {
this.speedX = Math.random()*4;
} else if (this._x>this.highX) {
this.speedX = -Math.random()*4;
}
if (this._y<this.lowY) {
this.speedY = Math.random()*4;
} else if (this._y>this.highY) {
this.speedY = -Math.random()*4;
}
this._x += this.speedX;
this._y += this.speedY;
};
setInterval( function(){
trace("interval called");
this.duplicateMovieClip("clip"+globali,globali);
particle.apply(_root["clip"+globali]);
_root["clip"+i]._alpha=random(100);
globali++;
}, 5000 );
this.onPress = function() {
this.duplicateMovieClip("clip"+globali,globali);
particle.apply(_root["clip"+globali]);
globali++;
};
// END define events
};
//
// main code
particle.prototype = new MovieClip();
for (i=0; i<1; i++) {
_root.attachMovie("ball", "ball"+i, 1000+i);
particle.apply(_root["ball"+i]);
_root["ball"+i]._alpha=random(100);
}
// END main code
It seems to work in the trace, but the actual movieclips aren’t appearing.
Here’s the original FLA as well for reference: www.globaleyes.ca/particles.fla
Thanks for any help!