# A little debuggin help please

**URL:** <https://forum.kirupa.com/t/a-little-debuggin-help-please/243545>\
**Category:** Uncategorized\
**Created:** [November 8, 2007, 5:03am UTC](https://forum.kirupa.com/t/a-little-debuggin-help-please/243545 "2007-11-08T05:03:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jibble](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jibble/32/2265_2.png) [@jibble](https://forum.kirupa.com/u/jibble)\
**Post date:** [November 8, 2007, 5:03am UTC](https://forum.kirupa.com/t/a-little-debuggin-help-please/243545/1 "2007-11-08T05:03:30Z")

</div>

How would i go about making this an onEnterFrame();

```auto
 fscommand("allowscale", false);
//Creates a unique ID number for each bounce function call
uniqueBounceID = 0;
function bounce(param, endingVal, clipName, speedFactor, bounceFactor) {
    //Do not run if the clipName does not exist
    if (clipName._x<>undefined) {
//Clear old setIntervals with same param name that might still be firing - prevents the clipName movie from being caught between two different parameter values
        clearInterval(_root["bounceInterval"+clipName[param+"ID"]]);
        //Reassign variables to make them private variables of the movie clip
        var bounceID = _root.uniqueBounceID++;
        clipName["param"+bounceID] = param;
        clipName["endingVal"+bounceID] = endingVal;
        clipName["speedFactor"+bounceID] = speedFactor;
        clipName["bounceFactor"+bounceID] = bounceFactor;
        clipName["startingParamVal"+bounceID] = clipName[param];
        clipName["changedParamVal"+bounceID] = 0;
//Store the bounceID for this parameter into a variable in the clipName movieclip - used to clear the setInterval if the movie clip is removed before the function completes
        clipName[param+"ID"] = bounceID;
        //Bounce function called from the setInterval
        clipName["callBounce"+bounceID] = function () {
            //If the clip no longer exists, clear the setInterval          
            if (clipName._x == undefined) {
                clearInterval(_root["bounceInterval"+bounceID]);
            } else {
                // Don't fire if the destination position is met   
                if (clipName["endingVal"+bounceID]<>Math.round(clipName[clipName["param"+bounceID]])) {
                    // Modify the changedParamVal by using a simple friction equation
clipName["changedParamVal"+bounceID] = clipName["changedParamVal"+bounceID]*clipName["bounceFactor"+bounceID]+(clipName["endingVal"+bounceID]-clipName["startingParamVal"+bounceID])/clipName["speedFactor"+bounceID];
                    // Increment the startingParamVal by the new changedParamVal
                    clipName["startingParamVal"+bounceID] += clipName["changedParamVal"+bounceID];
                    // Snaps bouncing object to the pixel to reduce blinking effect and keep fonts pixelized
                    clipName[clipName["param"+bounceID]] = Math.round(clipName["startingParamVal"+bounceID]);
                } else {
                    //Ensure final destination
                    clipName[clipName["param"+bounceID]] = clipName["endingVal"+bounceID];
                    // Clear the setInterval
                    clearInterval(_root["bounceInterval"+bounceID]);
                }
            }
            //trace(clipName+" "+bounceID+":"+clipName["param"+bounceID]+" = "+clipName[clipName["param"+bounceID]]);
        };
        //Call the bounce function 100 times per second
        _root["bounceInterval"+bounceID] = setInterval(clipName["callBounce"+bounceID], 10);
    }
}

```
