onClipEvent(load) { velocity = 0; gravity = .3; speed = 0; } onClipEvent(enterFrame) { this._y += velocity; velocity = velocity + gravity; this._x += speed; if (this._y > 337) { this._y = 337; velocity *= -1; /* Seeing as we've just hit the bottom wall, decrease * the life counter */ if (_root.life_text.text < 1) { _root.gotoAndStop(4); } else { _root.life_text.text -= 1; } } /* The velocity can't be more than 10 */ if (velocity > 10) { velocity=10; } /* Don't let it exit the stage */ if (this._y < 0) { this._y = 0; } /* If it hits the left part of the paddle, the * velocity is reversed as well as the speed */ if (this.hitTest(_root.pad.l)) { this._y = _root.pad._y - _root.pad._height - 3; velocity *= -1; speed = 5; speed *= -1; } /* Same thing with the right part */ if (this.hitTest(_root.pad.r)) { this._y = _root.pad._y - _root.pad._height - 3; velocity *= -1; speed = 5; } /* Reverse the speed of the ball */ if (this._x < 0) { this._x = 0; speed *= -1; } if (this._x > (550 - this._width)) { this._x = 550 - this._width; speed *= -1; } }