Array Problem: can't add Component

Hello everyone,
I can’t figure out why I am having this problem!
I have tried this with a game object and the code is like this:

var prefab:GameObject;
function Start () 
{  
  prefab = Instantiate (myHouse, gameObject.transform.position , Quaternion.identity);
  prefab.transform.parent = transform;	
  var script : ChangeCursor = prefab.AddComponent(ChangeCursor);
  script.OverCursor = OverCursor;
  script.DragCursor = DragCursor;
}

Everthing works fine here!
But I am trying the same method with array and I don’t see any change!
Here’s the code:

var next:GameObject = Instantiate(myArray[0],transform.position , Quaternion.identity);
next.transform.parent = transform;
var script : ChangeCursor = next.AddComponent(ChangeCursor);
next.OverCursor = OverCursor;
next.DragCursor = DragCursor;

I see next created when I run the game, also its a child to transform.
The only part not working is adding the component
next is a gameobject just as the prefab in the first code!
So what might be the problem? do i have to attach the component(script) to the whole array? or what else? plz some help

What’s wrong in the second script is the assignment of OverCursor and DragCursor: you’re using next instead of script - they should be:

var next:GameObject = Instantiate(myArray[0], transform.position, Quaternion.identity);
next.transform.parent = transform;
var script : ChangeCursor = next.AddComponent(ChangeCursor);
script.OverCursor = OverCursor; // <- these assignments were wrong!
script.DragCursor = DragCursor;

NOTE: I’m supposing that myArray is an GameObject array containing the prefabs - is it ok?