How to create animations via script.

I’ve created an animation clip and saved it out but when I then drag it to the object to animate I get yellow parameters shown in the animation window. Clicking on them selects the object that should be animated, but the animation does not drive the object (in play or edit mode). You can see in the screenshot that the current time is set to 0:22 and yet the values shown next to the properties on the left all read 0.

Any ideas? Anyone know what the yellow properties indicate, they are usually white / grey.

Code to create Assets/Test.anim

using UnityEngine;
using UnityEditor;
using System.Collections;

public class TestAnim : Editor
{
    [UnityEditor.MenuItem("TestAnim/Create Test")]
	public static void CreateAnim ()
    {
        AnimationClip clip = new AnimationClip();

        clip.SetCurve("", typeof(Transform), "position.x", AnimationCurve.EaseInOut(0, 0, 2, 10));
        clip.SetCurve("", typeof(Transform), "position.y", AnimationCurve.EaseInOut(0, 10, 2, 0));
        clip.SetCurve("", typeof(Transform), "position.z", AnimationCurve.EaseInOut(0, 5, 2, 2));

        AssetDatabase.CreateAsset(clip, "Assets/Test.anim");
	}	
}

Not sure why they are yellow. In my editor they turn Red, indicating that the values cannot be found. Try using “localPosition.x” instead as indicated by the documentation for SetCurve.