# 3D zooming problem

**URL:** <https://forum.kirupa.com/t/3d-zooming-problem/226596>\
**Category:** flash\
**Created:** [May 22, 2007, 2:46pm UTC](https://forum.kirupa.com/t/3d-zooming-problem/226596 "2007-05-22T14:46:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rameshkpalleri](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@rameshkpalleri](https://forum.kirupa.com/u/rameshkpalleri)\
**Post date:** [May 22, 2007, 2:46pm UTC](https://forum.kirupa.com/t/3d-zooming-problem/226596/1 "2007-05-22T14:46:31Z")

</div>

Hello wonderful people,

I Have a project which displays 8 images as an aisle.  
I need to zoom in and zoom out the images as 3D shelves. while zooming in, after a particular point the topmost image should go behind all the other… like a loop.  
zooming in is ok, but the zooming out is a problem… i donno how to controle it… its an easy job for pple who knows actionscript well but not for me… 😉

I used the tutorial “[kirupa.com - Shape Movement vs. Camera Offset](http://www.kirupa.com/developer/actionscript/shape_camera.htm)” to get the effect…  
it is working fine for the up arrow, even i donno whats happening inside… but  
when i press the down arrow all the 8 images are zooming out together.

Im attaching the file for your reference. as this is in a critical stage… please…please make it working…

Sorry, i cant attach the file… ill paste the code here.

> 

objectsInScene = new Array();

var zConstant:Number = 800  
var zValue:Number = 600

cameraView = new Object();  
cameraView.x = 0;  
cameraView.y = -100;  
cameraView.z = 0;  
cameraView.velocity = 0;  
focalLength = 300;

///////////\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
placeObjectIn3D = function(obj, x, y, z){  
var scaleRatio = focalLength/(focalLength + z);  
obj.\_x = x \* scaleRatio;  
obj.\_y = y \* scaleRatio;  
obj.\_xscale = obj.\_yscale = 100 \* scaleRatio;  
obj.swapDepths(Math.round(-z));  
};

// TIRES  
displayTire = function(clip){  
var x = clip.x - cameraView.x;  
var y = clip.y - cameraView.y;  
var z = clip.z - cameraView.z;  
if (z \< 0){  
clip.z += zConstant;  
z = clip.z - cameraView.z;  
}  
placeObjectIn3D(clip, x, y, z);  
};  
// Asils  
for (i=0; i\<4; i++){  
attachedObj = \_mc.attachMovie(“symbol”, “tire”+i,i);  
attachedObj.x = -150;  
attachedObj.z = zValue_i;  
attachedObj.y = 0;  
 [//attachedObj.display](https://attachedObj.display) = displayTire;  
objectsInScene.push(attachedObj);  
attachedObj.onPress = function(){  
trace(this.\_name)  
}  
}  
ddrive()  
function ddrive(){  
for (var i = 0; i \< objectsInScene.length; i++){  
displayTire(objectsInScene_);  
}  
}

drive = function(){  
ddrive()  
if (Key.isDown(Key.UP)) cameraView.velocity = 45;  
else cameraView.velocity = 0;  
if (Key.isDown(Key.DOWN)) cameraView.velocity = -25;  
cameraView.z += cameraView.velocity;  
for (var i = 0; i \< objectsInScene.length; i++){  
objectsInScene\*.display();  
}  
};  
//\_mc is a moviclip in stage  
\_mc.onEnterFrame = drive;
