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.
Having balls and flat figures can be fine to a degree, but often, your scene may require more than that flat look. Using pre-rendered elements, either hand-drawn, or more commonly pre-rendered in an external 3D application then imported into Flash can be used to enhance your 3D scene by adding a more realistic 3D impression.
Such elements would require a fully rendered frame-by-frame rendition with 360 degrees of rotation. That way, no matter what angle you are looking at the object, you will be able to see its correct side. Here is an example created in Swift3D.
[ a satellite dish rendered with 360 degrees of rotation ]
You can imagine yourself running around this satellite to view it at all angles as seen above. Using those angles of view, we can stick that element into a 3D scene to give a better sense of realism though only requiring Flash to calculate position and scaling for one single movieclip.
This will use the same methods of navigation as the example on Moving the Camera With Panning. Instead of figures, however, this example will use two pre-rendered satellite dishes. When moving around these dishes you will see them as they should appear in being perspectively correct (at least within the extents of their frames of animation).
[ perspectives for pre-rendered satellite dishes ]

[ frames of dish movieclip. onion skin shows rotation ]
frameFromAngle = function(r, frames){
r %= 2*Math.PI;
if (r < 0) r += 2*Math.PI;
return Math.floor(1 + frames * r/(2*Math.PI));
};
The first two statements
r %= 2*Math.PI;
if (r < 0) r += 2*Math.PI;
make sure the rotation passed is within a range of 0 to 2 Pi (we're dealing with radians here). r %= 2*Math.PI; uses mod (%) to bring the rotation down if its past 360 and if (r < 0) r += 2*Math.PI; keeps it from being negative. Following that, the return value is the frame calculated by deriving a ratio from r with 2 Pi radians, or a full circle, and multiplying that by frames.
returnMath.floor(1 + frames * r/(2*Math.PI));
An added 1 is included because frames in movieclips start at 1 and not 0 which would be a possible result from this equation.
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));
var perspectiveShift = x/radius;
var frame = frameFromAngle(angle+perspectiveShift, this._totalframes);
if (this._currentframe != frame) this.gotoAndStop(frame);
}else{
this._visible = false;
}
|
|
WARNING! Proximity and Pre-rendered 3D Elements |
|
First of all, using pre-rendered elements in such a 3D
scene is not an exact science. Such elements will be limited by the
number of frames which make them up - and the more frames you use, the
larger the file size of your movie, so you'll need to be careful of
that. But also, there can be undesirable perspectives, or at least
perspectives that don't appear to be visually correct, when you start to
get close to these objects.
This is because their frame is based on the rotation that element is in relation to the camera. When you get closer to the camera, you have a wider range of angles in a shorter range of space which could give you unusually fast changing perspectives which may appear not to match up with the view correctly. Besides, its not technically the view that the angle is based on, its the camera position. The extents of the view can actually extend beyond the camera as seen with the merry-go-round example. |
|
You may feel that you have learned everything there is to know about 3D in Flash, but there is still a bit more left. You do have cool examples though, so continue on.
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 //--