class Fireball1 extends MovieClip{ private var vy:Number; private var ay:Number; private var k:Number; private var damp:Number; private var ylimit:Number; private var graphic:Number; private var timeInterval:Number; private var lifeSpan:Number = 0; private var rand:Number; private var back:MovieClip; function fireInit() { _x = Math.random()*320 + 130; _y = Math.random()*20 + 280; back = attachMovie("b"+ graphic, "ball", 1); k = .1; damp = .9; ylimit = Math.random()*60 + 230; vy = Math.random()*3; rand = Math.floor(Math.random()*500) + 500; onEnterFrame = fireJump; // timeInterval = setInterval(this, "jump", rand); } function fireJump():Void { ay = (_y - ylimit)*k; vy += ay; _y -= vy; vy*damp; if(_y > 300){ vy = 0; } // increase lifeSpan variable lifeSpan++; // when it reaches 5, self destroy // note that because the class instance is also a movieclip subclass // the setInterval gets deleted along with the movieclip if (lifeSpan == 50) { removeMovieClip(this); } } }