Assign Names Problem

Hello , am having a really wiered problem with assiging names to prefabs am instantiating in the scene ,
each level I instantiate a number of objects in the scene and I specify a name for each , just using a for loop and adding i to the name of the objects,
here is the code:

var to_load:Number; // 3
for(var i:uint ; i < to_load ; i++){
		Instantiate (ball, Vector3(Random.Range(-3, 3), Random.Range(-3, 3), Random.Range(2, 8)), Quaternion.identity);
		ball.name = "ball"+i;
	}

everything is working perfectly except that if I change the variable to_load in the inspector and I play the game , it loads objects an skip somehow a number which causes to have an object without the correct name, but if I reload the level “without any modifications , just click stop then play again” it loads the objects as its suposed to , here are 2 screenshots to explain better:

This is First time load:
alt text

Second time load :
alt text

I tried many methods ,also to avoide the inspector but with no results , anyone has an Idea what could be causing this problem ?
thank you

I’m not particularly sure what you’re issue is (never used units before), however i changed some variables around and I believe this works. I basically got rid of your uint and instead declared to_load as an int:

var to_load: int = 3;

	for(i = 0; i <= to_load ; i++){
		Instantiate (ball, Vector3(Random.Range(-3, 3), Random.Range(-3, 3), Random.Range(2, 8)), Quaternion.identity);
		ball.name = "ball" + i;
	}

Hope that helps! Klep