# 3d in flash

**URL:** <https://forum.kirupa.com/t/3d-in-flash/189788>\
**Category:** flash\
**Created:** [June 6, 2006, 8:57am UTC](https://forum.kirupa.com/t/3d-in-flash/189788 "2006-06-06T08:57:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keljnr](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@keljnr](https://forum.kirupa.com/u/keljnr)\
**Post date:** [June 6, 2006, 8:57am UTC](https://forum.kirupa.com/t/3d-in-flash/189788/1 "2006-06-06T08:57:17Z")

</div>

Supposing that on the following tutorial: [http://www.kirupa.com/developer/actionscript/shape\_camera.htm](http://www.kirupa.com/developer/actionscript/shape_camera.htm)

Im wanting the function backAndForth to execute onRelease instead of onEnterFrame.

I have changed

```auto
theScene.Joe.onEnterFrame = backAndForth

```

to

```auto
theScene.Joe.onRelease = backAndForth

```

But on release the camera hardly moves, and you have to keep clicking the mc to get to the desired position. How can I get to so it moves smoothly, only having to click it the once.

Heres all the code for the tutorial:

```auto
theScene.Joe.x = 0;
theScene.Joe.y = 0;
theScene.Joe.z = 500;
 
cameraView = new Object();
cameraView.x = 0;
cameraView.y = 0;
cameraView.z = 500;
focalLength = 300;
dir = -1;
speed = 20;
 
backAndForth = function(){
 cameraView.z += speed*dir;
 if (cameraView.z > 500){
  cameraView.z = 500;
  dir = -1;
 }else if (cameraView.z < 0){
  cameraView.z = 0;
  dir = 1;
 }
 var scaleRatio = focalLength/(focalLength + this.z - cameraView.z);
 this._x = (this.x - cameraView.x) * scaleRatio;
 this._y = (this.y - cameraView.y) * scaleRatio;
 this._xscale = this._yscale = 100 * scaleRatio;
};
theScene.Joe.onEnterFrame = backAndForth;

```

Thanx :cool:
