All pastes #762124 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-05 12:08 UTC
rendered paste body
    public function bounce (prop : String, size : Number, gravity : Number, max : Number) {

        var i    : Number = 0;
        var move : Number = 0;
        var axis : String = '_' + prop;
        var B    : Number = this [axis];

        this.onEnterFrame = function () {

            if (i > max) {

                this.onEnterFrame = null;
            }

            move += gravity;

            this [axis] += move;

            if (this [axis] > B + size) {
                this [axis] = B + size;

                move *= -1;

                i++;
            }
        }
    }