# My drag n drop bouncing ball and hitTest

**URL:** <https://forum.kirupa.com/t/my-drag-n-drop-bouncing-ball-and-hittest/283882>\
**Category:** flash\
**Created:** [March 12, 2009, 2:28am UTC](https://forum.kirupa.com/t/my-drag-n-drop-bouncing-ball-and-hittest/283882 "2009-03-12T02:28:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)\
**Post date:** [March 12, 2009, 2:28am UTC](https://forum.kirupa.com/t/my-drag-n-drop-bouncing-ball-and-hittest/283882/1 "2009-03-12T02:28:31Z")

</div>

I have a drag and drop ball that begins with a 3 bounce animation. On hitTest with a basketball net it loads a subSWF called youWin2 into an empty movieclip called mySUB.

Because “dunking” the ball allows the ball to bounce 3 more times, it seems like the bounces appear to be triggering a reloading of my subSWF. The effect is of a blinking subSWF until the ball stops. It is as if the secondary bouncing is triggering additional hitTests. Does anyone have any ideas what might be causing the reloading of youWin2.swf?

```auto
on(press) {
    this._freefall = false;
    this._momentumY = 0;
    this.startDrag(false);
}

on(release, releaseOutside) {
    this._freefall = true;
    this.stopDrag();
}

onClipEvent(load) {
    this._freefall = true;
    this._momentumY = 0;
    this._accelerationY = 2.0;
    this._floorElasticity = 0.75;
    this._floorY = 290;
    this._bounceThreshold = 3;
}

onClipEvent(enterFrame) {
    if (this._freefall) {
        this._y += this._momentumY;
        this._momentumY += this._accelerationY;
        
        // bounce it off the floor if it has hit it
        if (this._y > this._floorY) {
            this._y = this._floorY;
            this._momentumY = -(this._momentumY * this._floorElasticity) + this._bounceThreshold;
            
            // keep it from jiggling infinitely
            if (Math.abs(this._momentumY) <= this._bounceThreshold) {
                this._momentumY = 0;
                
            }
        }
    }
}

onClipEvent(enterFrame) { 
  if(this.hitTest(_root.net_mc)){    
    _root.mySUB.loadMovie("youWin2.swf");    
   _root.net_mc.gotoAndPlay("net");    
    delete this.onEnterFrame
  }

}

```
