This is an archived tutorial from the kirupa.com legacy collection. It covers software that may no longer be available, but it is kept online because the ideas still hold up.
For reasons of simplicity, we'll ditch the movement for this example (though it's not at all hard to re-implement) and get back to basic panning. Here, however, as you can see, there's an extra added axis of rotation in this panning view. Not only can you look left and right, but also up!
[ looking up at balloon arches]
this.createEmptyMovieClip("theScene", 1);
theScene._x = 150;
theScene._y = 150;
objectsInScene = new Array();
cameraView = new Object();
cameraView.x = 0;
cameraView.y = -200;
cameraView.z = 0;
cameraView.rotation = 0;
cameraView.upAngle = 0;
focalLength = 300;
Something else a little different here is that the camera now has a y of -200. This is to more accurately reflect the fact that the camera is not on the same level as the horizon and that you actually have an elevated view as if you were standing and not just a head on the ground.
displayArch = function(){
var x = this.x - cameraView.x;
var y = this.y - cameraView.y;
var z = this.z - cameraView.z;
var tx, ty, tz; // temporary x, y and z variables
// rotation around y axis
var angle = cameraView.rotation;
tx = Math.cos(angle)*x - Math.sin(angle)*z;
tz = Math.sin(angle)*x + Math.cos(angle)*z;
x = tx;
z = tz;
// rotation around x axis
angle = cameraView.upAngle;
ty = Math.cos(angle)*y - Math.sin(angle)*z;
tz = Math.sin(angle)*y + Math.cos(angle)*z;
y = ty;
z = tz;
if (z > 0){
if (!this._visible) this._visible = true;
var scaleRatio = focalLength/(focalLength + z);
this._x = x * scaleRatio;
this._y = y * scaleRatio;
this._xscale = this._yscale = 100 * scaleRatio;
this.swapDepths(Math.round(-z));
}else{
this._visible = false;
}
};
lookAround = function(){
cameraView.rotation += this._xmouse/3000;
cameraView.upAngle += this._ymouse/3000;
if (cameraView.upAngle > 0) cameraView.upAngle = 0;
if (cameraView.upAngle < -Math.PI/2) cameraView.upAngle = -Math.PI/2;
for (var i=0; i < objectsInScene.length; i++){
objectsInScene[i].display();
}
var angle = cameraView.upAngle;
var distance = 9999999;
var y = Math.cos(angle)*cameraView.y - Math.sin(angle)*distance;
var z = Math.sin(angle)*cameraView.y + Math.cos(angle)*distance;
var scaleRatio = focalLength/(focalLength + z);
ground._y = theScene._y + (y * scaleRatio);
};
theScene.onEnterFrame = lookAround;
In that example there were 2 axes of rotation. All that remains in this total three-dimensional conquest is that final third axis - rotation around the z axis, or camera roll. This would be comparable to you tilting your head left or right down towards either your shoulder while still looking straight ahead thereby pretty much spinning the world in front of you. In terms of the first person perspectives of virtually all our previous examples, walking around and interacting with the environment, this act has little practicality. In fact, it generally also has little practicality in other 3D as well. The reason for this is that with just two axes of rotation, you have the ability to see or rotate in any direction in 3D giving you practically a full range of three dimensional rotation.
Just think back to the previous example. If there was no restriction on looking down, there would be no direction that you couldn't look in - and all this without the need of further rotation around the third remaining axis. In fact, much of the 3D you see online, when you see it, especially in Flash, doesn't take advantage of that third rotational axis, not only because, well, it's not needed. But also, if you consider that a mouse only really has two inputs in terms of direction (left and right or up and down), there isn't much room for controlling that third axis anyway. Given that any rotation can be met with just two, why bother with more? Well, I can think of some reasons, but I won't bother you with those now.
This is getting into the more popular and impressive display of 3D in Flash - what you really think of when you hear the term "3D." If you are one of those Flash developers who has a very 2D-based mind set, coming across a fully rotational 3D object in a Flash player is often, at least initially, very impressive. There's reason for that impression too; because it's not at all intuitive or really all that easy. Usually only those who know what they're doing in terms of 3D and the more complex math involved end up, well, doing it. So far, however, in following this tutorial, pretty much all that is needed to put this into effect has been discussed. The ground work has been done through the previous examples and only a small change in implementation is needed to achieve this new 3D effect.
Basically, the biggest difference here between the previous example which gave the ability of looking up is that, here, the camera object isn't used. Rotation here is applied directly to the shape and not the camera much in the same respect as the Merry Go Round example only with more rotation. This single shape is either perceived or alluded to through the rotation of solid shapes in a uniform manner, as the next example demonstrates, or something rendered with a 3D look using Flash's drawing methods based on theoretical points which are all rotating around a common center that which will be addressed later....in the next section.
That wraps up this tutorial. A huge thank you to all of you who buy kirupa's books, became a paid subscriber, watch the videos, and/or interact on the forums. Your support is what keeps writing like this online! 😇
This tutorial was written by senocular, also known as Trevor McCauley. He has been one of this community's most generous teachers since the early Flash days, and he is still around: find him on senocular.com and on the forums.
:: Copyright KIRUPA 2026 //--