Accessing another script from a class

I am trying to access other variables and functions from inside a class I have created using Javascript. For example:

script 1:

private var x

    public function setx(newX)
    {
      this.x = newx;
    }

script 2:

class Class1
{

  function doSomething()
  {
     script1.setx(1);
  }
};

How would I go about achieving this?

You could use the function GetComponent.

Look at the example in the reference.

You just need a reference to the instance script1.

http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

For example:

private var x;

public function SetX (x) {
    this.x = x;
}

.

class Class1 extends UnityEngine.Object {
    function DoSomething () {
        (FindObjectOfType(Script1) as Script1).SetX(1);
    }
}

I have found the answer. The reference link I needed to use was:

var Script1script = gameObject.GetComponent("script1");

Script1script.SetX(1);

Thanks for the help.