Accessing functions in other scripts.

In Javascript, I have tried the method listed here...

http://answers.unity3d.com/questions/32/how-do-i-call-a-function-in-another-gameobjects-script

...but following it got the error: Assets/HazardStatic.js(18,23): BCE0019: 'Test' is not a member of 'UnityEngine.GameObject'.

The scenario is thus: I have two scripts named Testing and HazardStatic both assigned to the same game object named HazFlowerCol.

In the Testing script are a static var named "test" and a static function named "Test".

I can access and change the var "test" but cannot trigger the function "Test".

I will vote answered to the answer that leads to my HazardStatic script being able to call the Test function in Testing. Please be explicit in your JavaScript answer as I have already been through everything I could on this page without success:

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

to no avail.

Thanks!

--Goody!

EDIT: added example with static and nonstatic functions/vars

If you use the method as in the docs you mentioned, you have to connect the script ScriptB to the other property of ScriptA. You do this by drag/dropping the gameobject self onto the property other of ScriptA in the inspector. For static functions and vars you refer them using the scriptname, e.g. ScriptB.staticVar or ScriptB.StaticFun().

Examples:

ScriptA

var other : ScriptB;

function Update () {
    other.testValue = 1;
    other.Test();
    other.staticTestValue = 2;
    ScriptB.StaticTest();
}

ScriptB

var testValue : int = 0;
static var staticTestValue : int = 0;

static function StaticTest() {
    Debug.Log("Static Test: " + staticTestValue);
}

function Test() {
    Debug.Log("Test: " + testValue);
}