Script:Drag and Drop, hittest

This is a script for a simple drag and drop action, which involves hittest. The scripts are shown for the drug icon and the growth factor. I took this tutorial from my cancer web site and it shows a biological application.

Drug icon

//Define the functions for the individual dragable clips,
//here for the drug icon
MovieClip.prototype.drugFun=function(){
    //drag function
    drug.onMouseDown=function() {
        //detect hit between mouse and object
        if(drug.hitTest(_root._xmouse,_root._ymouse, true)){
            //dragging permitted
            drug.startDrag();
        }
    }
    //stop drag function
    this.onMouseUp=function() {
        if(drug.hitTest(_root._xmouse,_root._ymouse, true)){
            drug.stopDrag();
        }
    }
    //function to detect contact between drug icon and growth
    //factor icon
    this.onEnterFrame=function() {
        if(drug.hitTest(growthfactor_1b)){
            //if hit positive, place the icon at a different 
            //location
            growthFactor_1a._x = 500;
            growthFactor_1a._y = 100;
            //play the receptor movieclip
            receptor.gotoAndPlay ("inhib");
        }
    }
}

Growth factor icon

//function for the growthfactor icon
MovieClip.prototype.factor=function(){
    this.onMouseDown=function() {
        if(this.hitTest(_root._xmouse,_root._ymouse, true)){
            this.startDrag();     
        }
    }
    this.onMouseUp=function() {
        if(this.hitTest(_root._xmouse,_root._ymouse, true)){
            this.stopDrag(); 
        }
    }
    this.onEnterFrame=function() {
        if(this.hitTest(growthfactor_1b)){
            receptor.gotoAndPlay ("activ");
        }
    }
}
//execute functions
drug.drugFun();
growthFactor_1a.factor();