# How to simulate a mouse click. Please help!

**URL:** <https://forum.kirupa.com/t/how-to-simulate-a-mouse-click-please-help/210405>\
**Category:** Uncategorized\
**Created:** [December 18, 2006, 3:34pm UTC](https://forum.kirupa.com/t/how-to-simulate-a-mouse-click-please-help/210405 "2006-12-18T15:34:13Z")\
**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 18, 2006, 3:34pm UTC](https://forum.kirupa.com/t/how-to-simulate-a-mouse-click-please-help/210405/1 "2006-12-18T15:34:13Z")

</div>

Hi. I have this movement, but for now it’s just working on click and I can’t seem to figure it out how to make it fluid and nice without clicking on it.

Here’s some parts of the code that I have so far. Thanks for the help.

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

// this is the function for displaying the star onscreen  
displayStar = function(cameraView, focalLength){  
var x = this.x - cameraView.x;  
var y = this.y - cameraView.y;  
var z = this.z - cameraView.z;  
if (z \< 0){  
this.z += 5000;  
this.x = 1500-Math.random()\*6000;  
this.y = 0;  
x = this.x - cameraView.x;  
y = this.y - cameraView.y;  
z = this.z - cameraView.z;  
}  
var scaleRatio = focalLength/(focalLength + z);  
this.\_x = x \* scaleRatio;  
this.\_y = y \* scaleRatio;  
this.\_xscale = this.\_yscale = 100 \* scaleRatio;  
this.swapDepths(Math.round(-z));

};

// define array to hold the objects in the scene  
objectsInScene = new Array();

// loop through and create 6 stars randomly in the scene  
for (i=1; i\<=6; i++){  
attachedObj = theScene.attachMovie(“star”+String(i), “star”+String(i), theScene.depth + String(i));  
attachedObj.x = 250 - Math.random()_500;  
attachedObj.y = 0;  
attachedObj.z = i_500;  
attachedObj.onPress = selectStar;  
attachedObj.display = displayStar;

```
objectsInScene.push(attachedObj);

```

}

// function controlling the camera ease and all displaying  
// for objects in the objectsInScene array  
easeToTarget = function(){  
// ease each camera point to its target point  
cameraView.x += (cameraView.target.x - cameraView.x)/5;  
cameraView.y += (cameraView.target.y - cameraView.y)/5;  
cameraView.z += (cameraView.target.z - cameraView.z)/5;

```
// run the display function for each object in objectsInScene array
for (var i=0; i&lt;objectsInScene.length; i++){
    objectsInScene*.display(cameraView, focalLength);
}

```

};

theScene.onEnterFrame = easeToTarget;
