# Need help. Please

**URL:** <https://forum.kirupa.com/t/need-help-please/210485>\
**Category:** Uncategorized\
**Created:** [December 19, 2006, 8:42am UTC](https://forum.kirupa.com/t/need-help-please/210485 "2006-12-19T08:42:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreipastuhov](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@andreipastuhov](https://forum.kirupa.com/u/andreipastuhov)\
**Post date:** [December 19, 2006, 8:42am UTC](https://forum.kirupa.com/t/need-help-please/210485/1 "2006-12-19T08:42:39Z")

</div>

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.
