# 3D tutorial problem

**URL:** https://forum.kirupa.com/t/3d-tutorial-problem/195299
**Category:** flash
**Created:** [July 30, 2006, 6:35pm UTC](https://forum.kirupa.com/t/3d-tutorial-problem/195299 "2006-07-30T18:35:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![chapster](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chapster](https://forum.kirupa.com/u/chapster)
#### Post date: [July 30, 2006, 6:35pm UTC](https://forum.kirupa.com/t/3d-tutorial-problem/195299/1 "2006-07-30T18:35:32Z")

</div>

I’m using the 3D tutorial for the merry-go-round-style animation with the mouse effect.  
The problem is my scaleRatio is not working correct.  
It scales the front cube above its normal size when it should never go beyond its 100 scale.  
[http://www.kirupa.com/developer/actionscript/camera\_panning.htm](http://www.kirupa.com/developer/actionscript/camera_panning.htm)

problem area:

```auto

cube._xscale = cube._yscale = 100* (scaleRatio);

```

```auto

var focalLength:Number;
var spin:Number;
var cubeArray:Array;
var angleStep:Number;

function init():Void {
	focalLength = 500;
	spin = 0;
	this.createEmptyMovieClip("cubeHolder", 1);
	cubeHolder._x = Stage.width/2;
	cubeHolder._y = 400;
	angleStep = 2*Math.PI/8;
	cubeArray = new Array();
	for (i=1; i<7; i++) {
		cube = cubeHolder.attachMovie("cube", "cube"+i, i);
		cube.angle = angleStep*i;
		cube.radius = 200;
		cube.x = Math.cos(cube.angle)*cube.radius;
		cube.z = Math.sin(cube.angle)*cube.radius;
		cube.y = 40;
		displayCubes(cube);
		push(attachedObj);
	}
}
init();
  	function displayCubes(cube:MovieClip,count:Number){
	var angle = cube.angle + spin;
	var x = Math.cos(angle)*cube.radius;
	var z = Math.sin(angle)*cube.radius;
	var y = cube.y;
	
	var scaleRatio = focalLength/(focalLength + z);
	cube._x = x * scaleRatio;
	cube._y = y * scaleRatio;
	var scale=70* (scaleRatio);
	trace("scale = "+scale)
	cube._xscale = cube._yscale = 100* (scaleRatio);

	//cube._xscale *= Math.sin(angle);
	cube.swapDepths(Math.round(-z));
};

```

Is there a way of controlling my scaleRatio so it can go from an even scale from 70 to 100 meaning the back cubes 70 and an evenly distributed scale as it comes to the front?

Thanks,
