How to control parenting in multiple functions

How can I control parenting and unparenting over multiple functions in one script, when I want to control the unparenting in OnCollisionExit it is not working, because it is unknown? Also the part about Parenting in the script refference is really short and does not really help.

function OnCollisionEnter(other : Collision)
    {
      var myTransform = other.transform;
      myTransform.parent = transform;
      //
      if(whatEver)
        {
         playerTransform.parent = null;
        }
   }
//
function OnCollisionExit(other : Collision)
    {
        //Unparenting will not work because myTransform is unknown, How to make it so, that I can   control it from OnEnter & OnExit??
    	//myTransform.parent = null;
    }

You need to declare the variable outside of the function to do that. Try replacing the first 3 lines with these:

var myTransform : Transform;

function OnCollisionEnter(other : Collision)
{
  myTransform = other.transform;
  //

This changes the scope of the myTransform variable from local to the OnCollisionEnter function to a class-wide scope so you can access it from anywhere in the class.