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
problem area:
cube._xscale = cube._yscale = 100* (scaleRatio);
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,