Need help. Please

Hi. I have this for function:

for (i=1; i<=10; i++){
attachedObj = theScene.attachMovie(“star”+String(i), “star”+String(i), theScene.depth + String(i));
attachedObj.x = 450 - Math.random()500;
attachedObj.y = 0;
attachedObj.z = i
500;

attachedObj.onPress = selectStar;
attachedObj.display = displayStar;

objectsInScene.push(attachedObj, attachedObjText);

}

and some other function that relates to it:

selectStar = function(){
cameraView.target.x = this.x;
cameraView.target.y = this.y;
cameraView.target.z = this.z;
}

How do I make this work without having to use onPress? It should randomly select one of the objects in the for function and move it to the new location.
Any help would be greatly appreciated.

Thanks.